UnbluFirebaseNotificationCoordinator
public class UnbluFirebaseNotificationCoordinator : NSObject
extension UnbluFirebaseNotificationCoordinator: MessagingDelegate
Facilitates notifications with Firebase.
You should only use this if you’re not inheriting your AppDelegate from UnbluFirebaseUIApplicationDelegate
.
-
The delegate for notification events received from Firebase. Set this to be notified of certain events such as device token updates and remote notifications.
Declaration
Swift
public weak var delegate: UnbluFirebaseNotificationCoordinatorDelegate?
-
Creates an instance of a
UnbluFirebaseNotificationCoordinator
Declaration
Swift
public override convenience init()
-
Should be called on start of the application if with the userInfo stored inside “launchOptions?[.remoteNotification] as? [AnyHashable: Any]”. Can be nil if no notification was clicked to open the application.
Throws
UnbluNotificationProcessingError
if the notification is unable to be processed by Unblu.Declaration
Swift
public func handleInitialRemoteNotification(userInfo: [AnyHashable : Any]?) throws
Parameters
userInfo
The data dictionary of the notification
-
Should be called on each notification the application receives and which requires to call a completionHandler. It will either call the completionHandler directly if it is an Unblu notification or it will throw an error if the notification is not an Unblu notification and must not be processed by the host application.
Throws
UnbluNotificationProcessingError
if the notification is unable to be processed by Unblu.Declaration
Swift
public func handleRemoteNotification(userInfo: [AnyHashable : Any], completionHandler: @escaping (UIBackgroundFetchResult) -> Void) throws
Parameters
userInfo
The data dictionary of the notification
completionHandler
Called when the notification is handled directly by Unblu
-
Should be called on each notification the application receives and which does not require to call a completionHandler. It will throw an error if the notification is not an unblu notification and must not be processed by the host application.
Throws
UnbluNotificationProcessingError
if the notification is unable to be processed by Unblu.Declaration
Swift
public func handleRemoteNotification(userInfo: [AnyHashable : Any]) throws
Parameters
userInfo
The data dictionary of the notification
-
Should be called as soon as the registration for remote notifications fails.
Declaration
Swift
public func failedToRegisterForRemoteNotifications(error: Error)
Parameters
error
Error cause for failing to register for remote notifications
-
The current device push notification token. This should be set every time the application receives a new token from the system.
Declaration
Swift
public func setDeviceToken(_ deviceToken: String?)
-
This method will be called once a token is available, or has been refreshed. Typically it will be called once per app start, but may be called more often, if token is invalidated or updated. In this method, you should perform operations such as: Uploading the FCM token to your application server, so targeted notifications can be sent. Subscribing to any topics.
Declaration
Swift
public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?)