UnbluNotificationApi
@objc
public class UnbluNotificationApi : NSObject
Interface to use notifications with unblu. As Firebase Cloud Messaging (FCM) SDK is build as a static library, we can not include it here. Most functions of this api should be called for specific notification callbacks typically fired in the AppDelegate.
Use UnbluUiApplicationDelegate as a base class for your AppDelegate to automatically get all functionalities. The source file for UnbluUiApplicationDelegate is shipped together with the SDK.
Unblu will display/handle notifications as shown in the following table.
Api helper to check mainly if notifications are from unblu or not
Unblu will display/handle notifications as shown in the following table.
| App state | New Message | Incoming Call |
| background | show notification | show notification |
| foreground unblu UI closed | show notification | Trigger UnbluUiEventApi.UiVisibilityRequest |
| foreground unblu UI open | Does nothing | Does nothing |
Whenever a notification is clicked, the event {@link com.unblu.coresdk.ui.IUnbluUiEventApi.UiVisibilityRequest} is triggered.
-
The instance of the UnbluNotificationApi
Declaration
Swift
public static let instance: UnbluNotificationApi
-
This delegate will be called, if a notifcation is NOT an unblu notification, but should be handled by the application.
Declaration
Swift
public weak var userNotificationCenterDelegate: UNUserNotificationCenterDelegate? { get set }
-
Should be called as soon as the registration for remote notifications via FCM worked and there is a device token
Declaration
Swift
public func successfullyRegisteredForRemoteNotifications(token: String)
Parameters
token
Token of the device
-
Should be called as soon as the registration for remote notifications via FCM failed
Declaration
Swift
public func failedToRegisterForRemoteNotifications(error: Error)
Parameters
error
Error cause for failing to register for remote notifications
-
Helper to check if a notification is actually an unblu notification or not
Declaration
Swift
public func isUnbluNotification(userInfo: [AnyHashable : Any]) -> Bool
Parameters
userInfo
The data dictionary of the notification
-
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.
Declaration
Swift
public func handleInitialRemoteNotification(userInfo: [AnyHashable : Any]?)
Parameters
userInfo
The data dictionary of the notification
-
Should be called on each notification the application receives and which does not require to call a completionHandler. It will return true if the notification was an unblu notification and must not be processed by the host application.
Declaration
Swift
public func handleRemoteNotification(userInfo: [AnyHashable : Any]) -> Bool
Parameters
userInfo
The data dictionary of the notification
Return Value
true if the notification is handled by unblu. False otherwise
-
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 call the notHandledByUnbluCallback, if it is no unblu notification.
Declaration
Swift
public func handleRemoteNotification(userInfo: [AnyHashable : Any], completionHandler: @escaping (UIBackgroundFetchResult) -> Void, notHandledByUnbluCallback: () -> Void)
Parameters
userInfo
The data dictionary of the notification
completionHandler
Called when the notification is handled directly by unblu
notHandledByUnbluCallback
Called when the notification is not handled by unblu