Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Jul 3, 2024
1 parent 99023c9 commit e7c7b09
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sources/RemoteMessaging/RemoteMessagingConfigFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import Configuration
import Foundation
import Networking

/**
* This protocol defines API for fetching RMF config from the server
*/
public protocol RemoteMessagingConfigFetching {
func fetchRemoteMessagingConfig() async throws -> RemoteMessageResponse.JsonRemoteMessagingConfig
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/RemoteMessaging/RemoteMessagingConfigProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import Common
import Foundation

/**
* This protocol defines API for processing RMF config file
* in order to find a message to be displayed.
*/
public protocol RemoteMessagingConfigProcessing {
var remoteMessagingConfigMatcher: RemoteMessagingConfigMatcher { get }

Expand Down
32 changes: 32 additions & 0 deletions Sources/RemoteMessaging/RemoteMessagingProcessing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,50 @@ import Common
import Configuration
import Foundation

/**
* This protocol defines API for providing RMF config matcher
* that contains values of matched attributes that the config
* file is evaluated against.
*
* Client apps should implement it and pass to a class implementing
* RemoteMessagingProcessing.
*/
public protocol RemoteMessagingConfigMatcherProviding {
func refreshConfigMatcher(using store: RemoteMessagingStoring) async -> RemoteMessagingConfigMatcher
}

/**
* This protocol defines API for Remote Messaging client in the app.
*/
public protocol RemoteMessagingProcessing {
/// Defines endpoint URL where the config file is available.
var endpoint: URL { get }

/// This holds the fetcher that downloads the config file from the server.
var configurationFetcher: RemoteMessagingConfigFetching { get }

/// This holds the config matcher provider that updates the config matcher before the config is evaluated.
var configMatcherProvider: RemoteMessagingConfigMatcherProviding { get }

/// Provides feature flag support for RMF.
var remoteMessagingAvailabilityProvider: RemoteMessagingAvailabilityProviding { get }

/**
* This function returns a config processor.
*
* Config processor performs evaluation of the JSON config file against the matcher containing
* app-specific, device-specific and user-specific matched attributes. Default implementation is provided.
*/
func configProcessor(for configMatcher: RemoteMessagingConfigMatcher) -> RemoteMessagingConfigProcessing

/**
* This is the entry point to RMF from the client app.
*
* This function fetches the config, updates config matcher, evaluates the config against the matcher
* and stores the result as needed. Client apps should call this function in order to refresh remote messages.
* When messages are updated, `RemoteMessagingStore.Notifications.remoteMessagesDidChange` notification is posted.
* Default implementation is provided.
*/
func fetchAndProcess(using store: RemoteMessagingStoring) async throws
}

Expand Down

0 comments on commit e7c7b09

Please sign in to comment.