iOS Push SDK (Modular)

This WebexConnectPush module enables your application to receive and handle push notifications.

Overview

This WebexConnectPush module enables your application to receive and handle push notifications. It abstracts the underlying push notification service, providing a customization support for notification management.

ClassesDescription
PushMessagingProviderPushMessagingProvider is a class that provides a singleton instance of PushMessaging.
WebexConnectAppDelegateWebexConnectAppDelegate is a class that conforms to the UIApplicationDelegate protocol.
PushMessagePushMessage is a structure that represents a push message.
PushMessaging ProtocolProtocol defining the basic structure for push notification handling.
FCMPushProvider ProtocolA protocol that defines the required functionalities for handling FCM push notifications.
PushTokenDelegate ProtocolProtocol defining the delegate methods for receiving push token related updates.
PushMessagingDelegate ProtocolProtocol defining the delegate methods for handling push message reception.
PushActionsDelegate ProtocolProtocol defining the delegate methods for handling push message actions.
InAppNotificationDelegate ProtocolThis protocol represents callback methods implemented in InAppNotificationViewBinder to listen for InAppNotification displayed events, action click events, and dismiss events.
InAppNotificationManager ProtocolThe InAppNotificationManager protocol defines the interface for managing in-app notifications. It extends the NSObject class.
InAppNotificationViewBinder ProtocolA protocol for managing the behavior of in-app notification views.
InAppNotificationViewBinderFactory ProtocolA factory protocol for creating instances of InAppNotificationViewBinder. Conforming types are responsible for handling a specific type of in-app notification.
InAppNotificationViewBinderDelegate ProtocolA delegate protocol for handling in-app notification events.
InAppModalNotificationViewBinderFactoryThis class is responsible for creating instances of InAppNotificationViewBinder for modal notifications.
InAppBannerNotificationViewBinderFactoryThis class is responsible for creating instances of InAppNotificationViewBinder for banner notifications.
StylesThis class represents the style configuration for an in-app notification view.
EnumsLists of all Enums used in the Push SDK.

WebexConnectAppDelegate

MethodsDescription
application(_:didFinishLaunchingWithOptions:)This method is used to initialize the SDK. It reads the configuration from the IMIconnectConfiguration.plist file. If the app is allowed to use push notifications, it will register the app for push notifications.
application(_:didRegisterForRemoteNotificationsWithDeviceToken:)This method is used to send the device token to the back end in order to be used to send push notification to the user.
application(_:didFailToRegisterForRemoteNotificationsWithError:)This method is called when the app failed to register with Apple Push Notification service (APNs).
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)This method is used to handle the received remote notification. Using this method a notification can be sent to the user or to notify the app with changes done on Webex Connect. A delivery report will be sent to the back end.
userNotificationCenter(_:willPresent:withCompletionHandler:)This method is used to handle the notification received when application is in the foreground.
userNotificationCenter(_:didReceive:withCompletionHandler:)This method is used to handle the notification response when the user responded to the notification by opening the application, dismissing the notification or choosing a UNNotificationAction.

PushMessaging Protocol

MethodsDescription
requestNotificationPermissionRequests the user's permission prompt to enable push notifications to display on iOS devices.
processPushToken(token:type:completionHandler)Processes the push notification token based on the token type.
setAppDelegateMethodSwizzlingEnabledThis method enables/disables method swizzling for application life cycle methods and remote notifications methods based on isEnabled parameter value.
setNotificationCenterMethodSwizzlingEnabledThis method Sets User Notification Center Delegate in Webex Connect SDK based on isEnabled parameter value. By default this will be set to TRUE and sets the User Notification Center Delegate.
isConnectPushMessageChecks if the provided dictionary represents a Connect push message. Returns true if the dictionary represents a Connect push message, false otherwise.
sendMessageStatus(forTransIds: status: completionHandler)This method is used to send the status of one or more messages identified by array of transactionIds. The results of the operation are reported through the completionHandler
sendMessageStatus(forTransId: status: interactiveData: completionHandler)This method is used to send the status message identified by transactionId. The results of the operation are reported through the completionHandler

FCMPushProvider Protocol

MethodsDescription
getToken()This method gets the FCM push registration token.
subscribeToTopic(_:completionHandler:)This method subscribes to a FCM topic. The completionHandler closure handles any errors that occur during the subscription process.
unsubscribeFromTopic(_:)This method unsubscribes from a given FCM topic.
fetchFcmToken(usingAPNSToken:, completionHandler:)This method fetches the FCM token using the provided Apple Push Notification Service (APNS) token.

PushTokenDelegate Protocol

MethodsDescription
didUpdatePushToken(_:type)Notifies the delegate when the device token is updated.

PushMessagingDelegate Protocol

MethodsDescription
didReceiveMessage(message:fromTap:)This method notifies the delegate when a push message is received.

PushActionsDelegate Protocol

MethodsDescription
handleAction(_:withIdentifier:forMessage:responseInfo:)Processes the specified action taken by the user on a given push message. This method is responsible for handling interactive actions triggered by the user from a push notification. If the action is successfully handled, it returns true; otherwise, the SDK will continue to process the action.

InAppNotificationDelegate Protocol

MethodsDescription
onNotificationDisplayed(_:)This method will be invoked when InApp Notification is displayed.
onNotificationClicked(_:action:value:)This method will be invoked when InApp Notification action is clicked.
onNotificationDismissed(_:)This method will be invoked when InApp Notification is dismissed.

InAppNotificationManager Protocol

MethodsDescription
registerViewFactory(_:)Registers a view factory responsible for creating in-app notification views.
displayInAppNotification(_:)Displays an in-app notification using the provided push message.

InAppNotificationViewBinder Protocol

MethodsDescription
bindMessage(_:)Binds the given push message to the notification view.
setViewStyle(_:)Sets the visual style of the notification view.
setTheme(_:)Sets the theme of the notification view.
getView()Retrieves the view controller associated with the notification view.

InAppNotificationViewBinderFactory Protocol

MethodsDescription
createNotificationView()Creates a new instance of InAppNotificationViewBinder for modal notifications.

InAppBannerNotificationViewBinderFactory

MethodsDescription
createNotificationView()Creates a new instance of InAppNotificationViewBinder for banner notifications.

Styles

StylesDescription
InAppNotificationViewStyleThis class represents the style configuration for an in-app notification view.
InAppNotificationButtonStyleThis class represents the style configuration for a button in an in-app notification.
InAppBannerNotificationViewStyleThis class represents the style configuration for a banner notification view, which is a subclass of InAppNotificationViewStyle.
InAppModalNotificationViewStyleThis class represents the style configuration for a modal notification view, which is a subclass of InAppNotificationViewStyle. Currently, it does not have any additional properties or methods, inheriting all properties and methods from InAppNotificationViewStyle.

Enums

EnumerationDescription
InAppNotificationThemeThis enumeration defines the themes available for in-app notifications: dark and light.
PushMessageStatusThis enumeration represents the status of a push message.
PushDisplayTypeThis enumeration represents the display type of a push message.
PushTokenTypeThis enumeration represents the type of push notification tokens that can be used within the application.

PushMessagingProvider

PushMessagingProvider is a class that provides a singleton instance of PushMessaging.

Properties

Property NameDescription
instanceThe singleton instance of PushMessaging.

Sample Code:

let push = PushMessagingProvider.instance
id<PushMessaging> push = [PushMessagingProvider instance];

WebexConnectAppDelegate Class

WebexConnectAppDelegate is a class that conforms to the UIApplicationDelegate protocol.

This class includes various application lifecycle methods related to remote notifications.

Methods

application(_:didFinishLaunchingWithOptions:)

This method is used to initialize the SDK. It reads the configuration from the IMIconnectConfiguration.plist file. If the app is allowed to use push notifications, it will register the app for push notifications.

Syntax: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [AnyHashable : Any]? = nil) -> Bool

Returns: A Boolean value indicating whether the app launch process was successful.

Parameter NameTypeDescription
applicationUIApplicationThe singleton app object.
launchOptions[UIApplication.LaunchOptionsKey : Any]?A dictionary indicating the reason the app was launched.

application(_:didRegisterForRemoteNotificationsWithDeviceToken:)

This method is used to send the device token to the back end in order to be used to send push notification to the user.

Syntax:func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)

Parameters

Parameter NameTypeDescription
applicationUIApplicationThe singleton app object.
deviceTokenDataA token that identifies the device to APNs.

application(_:didFailToRegisterForRemoteNotificationsWithError:)

This method is called when the app failed to register with Apple Push Notification service (APNs).

Syntax: func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error)

Parameters

Parameter NameTypeDescription
applicationUIApplicationThe singleton app object.
errorErrorThe error that occurred.

application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

This method is used to handle the received remote notification. Using this method a notification can be sent to the user or to notify the app with changes done on Webex Connect. A delivery report will be sent to the back end.

Syntax: func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)

Parameters

Parameter NameTypeDescription
applicationUIApplicationThe singleton app object.
userInfo[AnyHashable : Any]A dictionary that contains information related to the remote notification.
completionHandler@escaping (UIBackgroundFetchResult) -> VoidThe block to execute when the fetch operation is complete.

userNotificationCenter(_:willPresent:withCompletionHandler:)

This method is used to handle the notification received when application is in the foreground.

Syntax: func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)

Parameters

Parameter NameTypeDescription
notificationUNNotificationThe notification object being presented.
completionHandler@escaping (UNNotificationPresentationOptions) -> VoidThe block to execute with the presentation options.

userNotificationCenter(_:didReceive:withCompletionHandler:)

This method is used to handle the notification response when the user responded to the notification by opening the application, dismissing the notification or choosing a UNNotificationAction.

Syntax: func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)

Parameters

Parameter NameTypeDescription
centerUNUserNotificationCenterThe notification center that received the notification.
responseUNNotificationResponseThe user's response to the notification.
completionHandler@escaping () -> VoidThe block to execute when the user's response handling is complete.

PushMessage

PushMessage is a structure that represents a push message.

Properties

Property NameDescription
messageThe actual message of the push notification.
extrasAny additional data associated with the push message.
customTagsAny custom tags associated with the push message.
readAtThe date when the push message was read.
createdAtThe date when the push message was created.
submittedAtThe date when the push message was submitted.
deliveredAtThe date when the push message was delivered.
transactionIdThe transaction ID of the push message.
statusThe status of the push message.
titleThe title of the push message.
categoryThe category of the push message.
displayOptionsThe display options for the push message.
threadThe thread object associated with the push message.

PushDisplayOptions

A class represents display options of a push message.

Properties

NameReturn TypeDescription
isExpandableBoolBoolean value indicating whether the push message is expandable.
typePushDisplayTypeThe type of display for the push message.

PushInteractiveData

A class represents the Push interactive data.

Properties

NameReturn TypeDescription
actionStringThe action of the push interactive data.
categoryStringThe category of the push interactive data.
identifierStringThe identifier of the push interactive data.
valueStringThe value of the push interactive data.

Methods

init

Initializes a new instance of PushInteractiveData.

Syntax:public init(identifier: String? = nil, category: String? = nil, action: String? = nil, value: String? = nil)

Parameters:

ParameterTypeDescription
identifierStringThe identifier of the interactive data.
categoryStringThe category of the interactive data.
actionStringThe action of the interactive data.
valueStringThe value of the interactive data.

PushMessaging Protocol

Protocol defining the basic structure for push notification handling.

Properties

Property NameDescription
actionsDelegateDelegate responsible for handling push notification actions.
pushMessagingDelegateDelegate responsible for handling push messaging.
pushTokenDelegateDelegate responsible for updating the device token.
additionalAuthorizationOptionsAdditional authorization options to request when registering for push notifications.
fcmPushProviderProvides Firebase Cloud Messaging push services.
apnsTokenThe APNS token received from Apple Push Notification Service (APNS) registration.
fcmTokenThe FCM token received from Firebase Cloud Messaging (FCM) registration.
notificationCategoriesCategories for push notifications.
foregroundNotificationPresentationOptionsThe presentation options for notifications when the app is in the foreground.
inAppNotificationManagerAn instance for managing in-app notifications.

actionsDelegate

// Assign your custom actions delegate
let pushMessaging = PushMessagingProvider.instance
pushMessaging.actionsDelegate = self
// Assign your custom actions delegate
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
pushMessaging.actionsDelegate = self;

pushMessagingDelegate

// Assign your custom push messaging delegate
let pushMessaging = PushMessagingProvider.instance
pushMessaging.pushMessagingDelegate = self
// Assign your custom push messaging delegate
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
pushMessaging.pushMessagingDelegate = self;

pushTokenDelegate

// Assign your custom push token delegate
let pushMessaging = PushMessagingProvider.instance
pushMessaging.pushTokenDelegate = self
// Assign your custom push token delegate
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
pushMessaging.pushTokenDelegate = self;

additionalAuthorizationOptions

// Set additional authorization options
let pushMessaging = PushMessagingProvider.instance
pushMessaging.additionalAuthorizationOptions = [.provisional, .criticalAlert]
// Set additional authorization options
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
pushMessaging.additionalAuthorizationOptions = UNAuthorizationOptionProvisional | UNAuthorizationOptionCriticalAlert;

fcmPushProvider

// Assign your FCM push provider
let pushMessaging = PushMessagingProvider.instance
pushMessaging.fcmPushProvider = MyFCMPushProvider()
// Assign your FCM push provider
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
pushMessaging.fcmPushProvider = [[MyFCMPushProvider alloc] init];

apnsToken

// Access the APNS token
let pushMessaging = PushMessagingProvider.instance
if let apnsToken = pushMessaging.apnsToken {
    print("APNS Token: \(apnsToken)")
}
// Access the APNS token
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
NSString *apnsToken = pushMessaging.apnsToken;
if (apnsToken) {
    NSLog(@"APNS Token: %@", apnsToken);
}

fcmToken

// Access the FCM token
let pushMessaging = PushMessagingProvider.instance
if let fcmToken = pushMessaging.fcmToken {
    print("FCM Token: \(fcmToken)")
}
// Access the FCM token
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
NSString *fcmToken = pushMessaging.fcmToken;
if (fcmToken) {
    NSLog(@"FCM Token: %@", fcmToken);
}

notificationCategories

// Set custom notification categories
let pushMessaging = PushMessagingProvider.instance
let category = UNNotificationCategory(identifier: "MY_CATEGORY", actions: [], intentIdentifiers: [], options: [])
pushMessaging.notificationCategories = [category]
// Set custom notification categories
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
UNNotificationCategory *category = [UNNotificationCategory categoryWithIdentifier:@"MY_CATEGORY" actions:@[] intentIdentifiers:@[] options:0];
pushMessaging.notificationCategories = @[category];

foregroundNotificationPresentationOptions

// Set foreground notification presentation options
let pushMessaging = PushMessagingProvider.instance
pushMessaging.foregroundNotificationPresentationOptions = [.alert, .badge, .sound]
// Set foreground notification presentation options
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
pushMessaging.foregroundNotificationPresentationOptions = UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound;

inAppNotificationManager

// Access the in-app notification manager
let pushMessaging = PushMessagingProvider.instance
if let manager = pushMessaging.inAppNotificationManager {
    // Use the manager as needed
}
// Access the in-app notification manager
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
InAppNotificationManager *manager = pushMessaging.inAppNotificationManager;
if (manager) {
    // Use the manager as needed
}

Methods

requestNotificationPermission

Requests the user's permission prompt to enable push notifications to display on iOS devices.

Syntax: func requestNotificationPermission()

📘

Note

This method should be called manually only if the shouldRequestNotificationPermission value is set to false in the Configuration plist. If shouldRequestNotificationPermission is true, this method is automatically invoked after user registration.

Sample Code:

// Request notification permission
let pushMessaging = PushMessagingProvider.instance
pushMessaging.requestNotificationPermission()
// Request notification permission
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
[pushMessaging requestNotificationPermission];

processPushToken(token:type:completionHandler)

Processes the push notification token based on the token type.

Syntax: func processPushToken(_ token: String, type: PushTokenType, completionHandler: @escaping (Error?) -> Void)

Parameters

Parameter NameTypeDescription
tokenStringA String representing the device token received from the push notification service.
typePushTokenTypeThe PushTokenType indicating whether the token is for APNS or FCM.
completionHandler(Error?) -> VoidA closure of type (Error?) -> Void that is called when the operation is complete. This closure contains an optional error.

Sample Code:

// Process a push token
let pushMessaging = PushMessagingProvider.instance
pushMessaging.processPushToken("token_string", type: .apns) { error in
    if let error = error {
        print("Failed to process token: \(error.localizedDescription)")
    } else {
        print("Token processed successfully")
    }
}
// Process a push token
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
[pushMessaging processPushToken:@"token_string" type:PushTokenTypeApns completionHandler:^(NSError *error) {
    if (error) {
        NSLog(@"Failed to process token: %@", error.localizedDescription);
    } else {
        NSLog(@"Token processed successfully");
    }
}];

setAppDelegateMethodSwizzlingEnabled

This method enables/disables method swizzling for application life cycle methods and remote notifications methods based on isEnabled parameter value.

Syntax func setAppDelegateMethodSwizzlingEnabled(_ isEnabled: Bool)

Parameters

ParameterTypeDescription
isEnabledBoolA boolean value indicating whether to enable (true) or disable (false) method swizzling.

Sample Code:

// Enable method swizzling
let pushMessaging = PushMessagingProvider.instance
pushMessaging.setAppDelegateMethodSwizzlingEnabled(true)
// Enable method swizzling
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
[pushMessaging setAppDelegateMethodSwizzlingEnabled:YES];

setNotificationCenterMethodSwizzlingEnabled

This method Sets User Notification Center Delegate in Webex Connect SDK based on _isEnabled parameter value. By default this will be set to TRUE and sets the User Notification Center Delegate.

Syntax: func setNotificationCenterMethodSwizzlingEnabled(_isEnabled: Bool)

Parameters

ParameterTypeDescription
isEnabledBoolA boolean value indicating whether to set (true) or ignore (false) User Notification Center Delegate.

Sample Code:

// Enable notification center method swizzling
let pushMessaging = PushMessagingProvider.instance
pushMessaging.setNotificationCenterMethodSwizzlingEnabled(true)
// Enable notification center method swizzling
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
[pushMessaging setNotificationCenterMethodSwizzlingEnabled:YES];

isConnectPushMessage(userInfo:)

Checks if the provided dictionary represents a Connect push message. Returns true if the dictionary represents a Connect push message, false otherwise.

Syntax: func isConnectPushMessage(userInfo: [String: Any]) -> Bool

Parameters

ParameterTypeDescription
userInfo[String: Any]The dictionary containing push notification information.

Sample Code:

// Check if a push payload is a Connect push message
let pushMessaging = PushMessagingProvider.instance
let isConnect = pushMessaging.isConnectPushMessage(userInfo: userInfo)
print("Is Connect push message: \(isConnect)")
// Check if a push payload is a Connect push message
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
BOOL isConnect = [pushMessaging isConnectPushMessageWithUserInfo:userInfo];
NSLog(@"Is Connect push message: %@", isConnect ? @"YES" : @"NO");

sendMessageStatus(forTransIds: status: completionHandler)

This method is used to send the status of one or more messages identified by array of transactionIds. The results of the operation are reported through the completionHandler

Syntax: func sendMessageStatus(forTransIds transIds: [String], status: PushMessageStatus, completionHandler: @escaping (Error?) -> Void)

Parameters

ParameterTypeDescription
transIds[String]The transaction IDs of the messages.
statusPushMessageStatusThe status of the message either delivered or read.
completionHandler:@escaping (Error?) -> VoidThe function to call when the operation is complete.

Sample Code:

// Send status for multiple messages
let pushMessaging = PushMessagingProvider.instance
let transIds = ["id1", "id2"]
pushMessaging.sendMessageStatus(forTransIds: transIds, status: .delivered) { error in
    if let error = error {
        print("Failed to send status: \(error.localizedDescription)")
    } else {
        print("Status sent successfully")
    }
}
// Send status for multiple messages
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
NSArray *transIds = @[@"id1", @"id2"];
[pushMessaging sendMessageStatusForTransIds:transIds status:PushMessageStatusDelivered completionHandler:^(NSError *error) {
    if (error) {
        NSLog(@"Failed to send status: %@", error.localizedDescription);
    } else {
        NSLog(@"Status sent successfully");
    }
}];

sendMessageStatus(forTransId: status: interactiveData: completionHandler)

This method is used to send the status message identified by transactionId. The results of the operation are reported through the completionHandler

Syntax: func sendMessageStatus(forTransId transId: String, status: PushMessageStatus, interactiveData: PushInteractiveData?, completionHandler: @escaping (Error?) -> Void)

Parameters

ParameterTypeDescription
transIdStringThe transaction ID whose status is to be sent.
statusPushMessageStatusThe status of the message.
interactiveDataPushInteractiveDataThe interactive data to be sent with the message status.
completionHandler(Error?) -> Void)The callback function to be invoked after sending the message status.

Sample Code:

// Send status for a single message with interactive data
let pushMessaging = PushMessagingProvider.instance
let interactiveData = PushInteractiveData()
pushMessaging.sendMessageStatus(forTransId: "id1", status: .read, interactiveData: interactiveData) { error in
    if let error = error {
        print("Failed to send status: \(error.localizedDescription)")
    } else {
        print("Status sent successfully")
    }
}
// Send status for a single message with interactive data
id<PushMessaging> pushMessaging = [PushMessagingProvider instance];
PushInteractiveData *interactiveData = [[PushInteractiveData alloc] init];
[pushMessaging sendMessageStatusForTransId:@"id1" status:PushMessageStatusRead interactiveData:interactiveData completionHandler:^(NSError *error) {
    if (error) {
        NSLog(@"Failed to send status: %@", error.localizedDescription);
    } else {
        NSLog(@"Status sent successfully");
    }
}];

FCMPushProvider Protocol

A protocol that defines the required functionalities for handling FCM (Firebase Cloud Messaging) push notifications.

Methods

getToken()

This method gets the FCM push registration token.

Syntax: func getToken() -> String?

subscribeToTopic(_:completionHandler:)

This method subscribes to a FCM topic. The completionHandler closure handles any errors that occur during the subscription process.

Syntax: func subscribeToTopic(_ topic: String, completionHandler: @escaping (Error?) -> Void)

Parameter NameTypeDescription
topicStringThe topic to subscribe to.
completionHandler(Error?) -> VoidA closure that handles any errors that occur during the subscription process.

unsubscribeFromTopic(_:)

This method unsubscribes from a given FCM topic.

Syntax: func unsubscribeFromTopic(_ topic: String)

Parameter NameTypeDescription
topicStringThe topic to unsubscribe from.

fetchFcmToken(usingAPNSToken:, completionHandler:)

This method fetches the FCM token using the provided Apple Push Notification Service (APNS) token.

Syntax: func fetchFcmToken(usingAPNSToken data: Data, completionHandler: @escaping (String?, Error?) -> Void)

Parameters

Parameter Name TypeDescription
dataDataThe APNS token in Data format, typically obtained from didRegisterForRemoteNotificationsWithDeviceToken
completionHandler(String?, Error?) -> VoidA closure that takes two optional parameters:

- String?: The FCM token if successful, or nil if an error occurs.
- Error?: An error object if the token retrieval fails, or nil if successful.

Sample Code:

Create a class that will confirm to FCMPushProvider protocol and implements the FCM related methods as shown below:

import Foundation 
import FirebaseCore 
import FirebaseMessaging 
import WebexConnectPush 
import WebexConnectCore 

class FCMTokenManager: NSObject, MessagingDelegate, FCMPushProvider { 
    var fcmToken: String? 
    override init() { 
        super.init() 
        FirebaseApp.configure() 
        Messaging.messaging().delegate = self 
    } 
    func getToken() -> String? { 
        return self.fcmToken 
    } 
    func fetchFcmToken(usingAPNSToken data: Data, completionHandler: @escaping (String?, Error?) -> Void) { 

		#if DEBUG 
        let apnsTokenType: MessagingAPNSTokenType = .sandbox 
		#else 
        let apnsTokenType: MessagingAPNSTokenType = .unknown 
		#endif 
        Messaging.messaging().setAPNSToken(data, type: apnsTokenType) 
        Messaging.messaging().token { newFcmToken, error in 
            self.fcmToken = newFcmToken 
            completionHandler(newFcmToken, error) 
        } 
    } 
    func subscribeToTopic(_ topic: String, completionHandler: @escaping (Error?) -> Void) { 
        Messaging.messaging().subscribe(toTopic: topic, completion: completionHandler) 
    } 
    func unsubscribeFromTopic(_ topic: String) { 
        Messaging.messaging().unsubscribe(fromTopic: topic) 
    } 
    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { 
        print("FCM registration token: \(String(describing: fcmToken))") 
        self.fcmToken = fcmToken 
        processFCMPushToken() 
    } 
    func processFCMPushToken() { 
        if let fcmToken, WebexConnectProvider.instance.isRegistered { 
            PushMessagingProvider.instance.processPushToken(fcmToken, type: .fcm, completionHandler: { _ in }) 
        } 
    } 
} 

PushTokenDelegate Protocol

Protocol defining the delegate methods for receiving push token related updates.

Methods

didUpdatePushToken(_ :type:)

Notifies the delegate when the device token is updated.

Syntax: func didUpdatePushToken(_ pushToken: String, type: PushTokenType)

Parameters

Parameter NameTypeDescription
pushTokenStringThe updated push token received from the push provider.
typePushTokenTypeThe PushTokenType indicating whether the token is for APNS or FCM.

PushMessagingDelegate Protocol

Protocol defining the delegate methods for handling push message reception.

Methods

didReceiveMessage(message:fromTap:)

This method notifies the delegate when a push message is received.

Syntax: func didReceiveMessage(message: PushMessage, fromTap: Bool)

Parameters

Parameter NameTypeDescription
messagePushMessageThe data representing the received push message.
fromTapBoolA boolean indicating whether the message was received due to a user tap.

PushActionsDelegate Protocol

Protocol defining the delegate methods for handling push message actions.

Methods

handleAction(_:withIdentifier:forMessage:responseInfo:)

Processes the specified action taken by the user on a given push message. This method is responsible for handling interactive actions triggered by the user from a push notification. If the action is successfully handled, it returns true; otherwise, the SDK will continue to process the action.

Syntax: func handleAction(_ action: String, withIdentifier identifier: String, forMessage message: PushMessage, responseInfo: [String: Any]?) -> Bool

Parameters

Parameter NameTypeDescription
actionStringThe action string that identifies what action the user took.
identifierStringThe identifier of the action that was taken by the user.
messagePushMessageThe PushMessage object that the action is related to.
responseInfo[String: Any]?Additional response information, if any, provided by the user.

Return Type: Bool

Returns true if the action was handled successfully; otherwise, false indicating the SDK should handle the action.

InAppNotificationDelegate Protocol

This protocol represents callback methods implemented in InAppNotificationViewBinder to listen for InAppNotification displayed events, action click events, and dismiss events.

Methods

onNotificationDisplayed(:)

This method will be invoked when InApp Notification is displayed.

Syntax: func onNotificationDisplayed(_ message: PushMessage)

Parameters

Parameter NameTypeDescription
messagePushMessageThe received PushMessage.

onNotificationClicked(_ : action: value:)

This method will be invoked when InApp Notification action is clicked.

Syntax: func onNotificationClicked(_ message: PushMessage, withAction action: String, value: String)

Parameters

Parameter NameTypeDescription
messagePushMessageThe received PushMessage.
actionStringAction to perform when interaction takes place.
valueStringValue used to complete certain actions.

onNotificationDismissed(:)

This method will be invoked when InApp Notification is dismissed.

Syntax: func onNotificationDismissed(_ message: PushMessage)

Parameters

Parameter NameTypeDescription
messagePushMessageThe received PushMessage.

InAppNotificationManager Protocol

The InAppNotificationManager protocol defines the interface for managing in-app notifications. It extends the NSObject class.

Properties

Property NameDescription
inAppdelegateThe delegate for handling in-app notification events.

Methods

registerViewFactory(_:)

Registers a view factory responsible for creating in-app notification views.

Syntax: func registerViewFactory(_ notificationFactory: InAppNotificationViewBinderFactory)

Parameters

Parameter NameTypeDescription
notificationFactoryInAppNotificationViewBinderFactoryAn object conforming to the InAppNotificationViewBinderFactory protocol, used for creating in-app notification views.

displayInAppNotification(_:)

Displays an in-app notification using the provided push message.

Syntax: func displayInAppNotification(_ message: PushMessage)

Parameters

Parameter NameTypeDescription
messagePushMessageThe push message containing information about the in-app notification to be displayed.

Sample Code:

let notificationManager = PushMessagingProvider.instance.inAppNotificationManager 
notificationManager?.inAppdelegate = self 
notificationManager?.registerViewFactory(InAppNotificationModalViewBinderFactory()) 
id<PushMessaging> push = [PushMessagingProvider instance]; 
id<InAppNotificationManager> inAppNotificationManager = [push inAppNotificationManager]; 
 inAppNotificationManager.inAppdelegate = self; 
 [inAppNotificationManager registerViewFactory:[[InAppNotificationModalViewBinderFactory alloc] init]]; 

InAppNotificationViewBinder Protocol

A protocol for managing the behavior of in-app notification views.

Properties

Property NameDescription
pushMessageThe push message associated with the notification.
delegateThe delegate object that will receive notifications from the view binder.

Methods

bindMessage(_:)

Binds the given push message to the notification view.

Syntax: func bindMessage(_ message: PushMessage)

Parameters

Parameter NameTypeDescription
messagePushMessageThe push message to be bound to the view.

setViewStyle(_:)

Sets the visual style of the notification view.

Syntax: func setViewStyle(_ style: InAppNotificationViewStyle)

Parameters

Parameter NameTypeDescription
styleInAppNotificationViewStyleThe visual style to be applied to the view.

setTheme(_:)

Sets the theme of the notification view.

Syntax: func setTheme(_ theme: InAppNotificationTheme)

Parameters

Parameter NameTypeDescription
themeInAppNotificationThemeThe theme to be applied to the view.

getView()

Retrieves the view controller associated with the notification view.

Syntax: func getView() -> UIViewController

Parameters

Return TypeDescription
UIViewControllerThe view controller that represents the notification view.

InAppNotificationViewBinderFactory Protocol

A factory protocol for creating instances of InAppNotificationViewBinder. Conforming types are responsible for handling a specific type of in-app notification.

Properties

Property NameDescription
notificationTypeIndicates the type of the message part handled by the factory.

Methods

Method NameDescription
createNotificationView()Creates a new InAppNotificationViewBinder instance.

createNotificationView()

Creates a new InAppNotificationViewBinder instance.

Syntax: public func createNotificationView() -> InAppNotificationViewBinder

Parameters

Return TypeDescription
InAppNotificationViewBinderA new instance of InAppNotificationViewBinder.

InAppNotificationViewBinderDelegate Protocol

A delegate protocol for handling in-app notification events.

Methods

Method NameDescription
onNotificationDisplayed(_:)Invoked whenever an in-app notification is displayed.
onNotificationClicked(_:withAction:value:)Invoked whenever an in-app notification is clicked.
onNotificationDismiss(_:)Invoked whenever an in-app notification is dismissed.

onNotificationDisplayed(_:)

Invoked whenever an in-app notification is displayed.

Syntax: func onNotificationDisplayed(_ message: PushMessage)

Parameters

ParameterDescription
messageThe received PushMessage object.

onNotificationClicked(_:withAction:value:)

Invoked whenever an in-app notification is clicked.

Syntax: func onNotificationClicked(_ message: PushMessage, withAction action: String, value: String)

Parameters

ParameterTypeDescription
messagePushMessageThe received PushMessage object.
actionStringThe received action type as a String.
valueStringThe received value as a String.

onNotificationDismiss(_:)

Invoked whenever an in-app notification is dismissed.

Syntax: func onNotificationDismissed(_ message: PushMessage)

Parameters

ParameterDescription
messageThe received PushMessage object.

InAppNotificationModalViewBinderFactory

This class is responsible for creating instances of InAppNotificationViewBinder for modal notifications.

Properties:

Property NameDescription
notificationTypeIndicates the type of the notification to be created. Default is .modal.

Methods

createNotificationView()

Creates a new instance of InAppNotificationViewBinder for modal notifications.

Syntax: public func createNotificationView() -> InAppNotificationViewBinder

Returns: A new instance of InAppNotificationViewBinder configured for modal notifications.

Sample Code

let factory = InAppNotificationModalViewBinderFactory()
let modalNotificationView = factory.createNotificationView()

In the example above, a new instance of InAppNotificationViewBinder configured for modal notifications is created using the factory.

InAppNotificationBannerViewBinderFactory

This class is responsible for creating instances of InAppNotificationViewBinder for banner notifications.

Properties

Property NameDescription
notificationTypeIndicates the type of the notification to be created. Default is .banner.

Methods

createNotificationView()

Creates a new instance of InAppNotificationViewBinder for banner notifications.

Syntax: public func createNotificationView() -> InAppNotificationViewBinder

Returns: A new instance of InAppNotificationViewBinder configured for banner notifications.

let factory = InAppNotificationBannerViewBinderFactory()
let bannerNotificationView = factory.createNotificationView()

In the example above, a new instance of InAppNotificationViewBinder configured for banner notifications is created using the factory.

Styles

InAppNotificationViewStyle

This class represents the style configuration for an in-app notification view.

Properties:

Property NameDescription
titleTextColorThe text color for the notification title label.
titleTextFontThe text font for the notification title label.
titleTextShadowColorThe shadow color for the notification title label text.
textColorThe text color for the notification details label.
textFontThe text font for the notification details label.
textShadowColorThe shadow color for the notification details label text.
backgroundColorThe background color for the notification view.
buttonStyleThe style configuration for notification buttons.

Initialization: The init() method initializes the notification view style with default values.

Sample Code:

let style = InAppNotificationViewStyle()
style.titleTextColor = .blue
style.titleTextFont = UIFont.boldSystemFont(ofSize: 18)
style.backgroundColor = .white

In the example above, an instance of InAppNotificationViewStyle is created and its properties are configured with custom values.

InAppNotificationButtonStyle

This class represents the style configuration for a button in an in-app notification.

Properties

Property NameDescription
buttonTextColorThe text color for the notification button.
buttonTintColorThe tint color for the notification button.
buttonTypeThe type of the notification button.
buttonBackgroundColorThe background color for the notification button.

Initialization: The init()method initializes the notification button style with default values.

Sample Code:

let buttonStyle = InAppNotificationButtonStyle()

buttonStyle.buttonTextColor = .white

buttonStyle.buttonTintColor = .blue

buttonStyle.buttonType = .system

buttonStyle.buttonBackgroundColor = .gray

In the example above, an instance of InAppNotificationButtonStyle is created and its properties are configured with custom values.

InAppNotificationBannerViewStyle

This class represents the style configuration for a banner notification view, which is a subclass of InAppNotificationViewStyle.

Properties

Property NameDescription
closeButtonTintColorThe tint color for the close button of the banner notification.
closeButtonBackgroundColorThe background color for the close button of the banner notification.
closeButtonImageThe image for the close button of the banner notification.

Methods:

init()

Initializes the banner notification view style with default values.

Syntax: public override init()

init(darkThemeStyle:)

Initializes the banner notification view style with dark theme style.

Syntax: public init(darkThemeStyle: Bool)

Parameters

Parameter NameTypeDescription
darkThemeStyleBoolA Boolean value indicating whether to apply the dark theme style.

init(lightThemeStyle:)

Initializes the banner notification view style with light theme style as a convenience initializer.

Syntax: public convenience init(lightThemeStyle: Bool)

Parameters

Parameter NameTypeDescription
lightThemeStyleBoolA Boolean value indicating whether to apply the light theme style.

Sample Code

// Create a banner notification view style with default values
let bannerStyle = InAppNotificationBannerViewStyle()
// Create a banner notification view style with dark theme style
let darkBannerStyle = InAppNotificationBannerViewStyle(darkThemeStyle: true)
// Create a banner notification view style with light theme style
let lightBannerStyle = InAppNotificationBannerViewStyle(lightThemeStyle: true)

InAppNotificationModalViewStyle

This class represents the style configuration for a modal notification view, which is a subclass of InAppNotificationViewStyle. Currently, it does not have any additional properties or methods, inheriting all properties and methods from InAppNotificationViewStyle.

Methods

init()

Initializes the modal notification view style with default values.

Syntax: public override init()

init(darkThemeStyle:)

Initializes the modal notification view style with dark theme style.

Syntax: public init(darkThemeStyle: Bool)

Parameters

Parameter NameTypeDescription
darkThemeStyleBoolA Boolean value indicating whether to apply the dark theme style.

init(lightThemeStyle:)

Initializes the modal notification view style with light theme style as a convenience initializer.

Syntax: public convenience init(lightThemeStyle: Bool)

Parameters

Parameter NameTypeDescription
lightThemeStyleBoolA Boolean value indicating whether to apply the light theme style.

Sample Code

// Create a modal notification view style with default values
let modalStyle = InAppNotificationModalViewStyle()
// Create a modal notification view style with dark theme style
let darkModalStyle = InAppNotificationModalViewStyle(darkThemeStyle: true)
// Create a modal notification view style with light theme style
let lightModalStyle = InAppNotificationModalViewStyle(lightThemeStyle: true)

Enums

InAppNotificationTheme

This enumeration defines the themes available for in-app notifications: dark and light.

ValueDescription
darkRepresents the dark theme for in-app notifications.
lightRepresents the light theme for in-app notifications.

PushMessageStatus

This enumeration represents the status of a push message.

ValueDescription
deliveredRepresents a case where the push message has been delivered.
readRepresents a case where the push message has been read.

PushDisplayType

This enumeration represents the display type of a push message.

ValueDescription
noneRepresents a case where the display type of a push message is not defined.
bannerRepresents a case where the push message is displayed as a banner.
modalRepresents a case where the push message is displayed as a modal.

PushTokenType

This enumeration represents the type of push notification tokens that can be used within the application.

ValueDescription
apnsRepresents the Apple Push Notification service (APNS) token type used for delivering notifications to iOS devices.
fcmRepresents the Firebase Cloud Messaging (FCM) token type used for delivering notifications to iOS devices.