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.
Classes | Description |
---|---|
PushMessagingProvider | PushMessagingProvider is a class that provides a singleton instance of PushMessaging. |
WebexConnectAppDelegate | WebexConnectAppDelegate is a class that conforms to the UIApplicationDelegate protocol. |
PushMessage | PushMessage is a structure that represents a push message. |
PushMessaging Protocol | Protocol defining the basic structure for push notification handling. |
FCMPushProvider Protocol | A protocol that defines the required functionalities for handling FCM push notifications. |
PushTokenDelegate Protocol | Protocol defining the delegate methods for receiving push token related updates. |
PushMessagingDelegate Protocol | Protocol defining the delegate methods for handling push message reception. |
PushActionsDelegate Protocol | Protocol defining the delegate methods for handling push message actions. |
InAppNotificationDelegate Protocol | This protocol represents callback methods implemented in InAppNotificationViewBinder to listen for InAppNotification displayed events, action click events, and dismiss events. |
InAppNotificationManager Protocol | The InAppNotificationManager protocol defines the interface for managing in-app notifications. It extends the NSObject class. |
InAppNotificationViewBinder Protocol | A protocol for managing the behavior of in-app notification views. |
InAppNotificationViewBinderFactory Protocol | A factory protocol for creating instances of InAppNotificationViewBinder. Conforming types are responsible for handling a specific type of in-app notification. |
InAppNotificationViewBinderDelegate Protocol | A delegate protocol for handling in-app notification events. |
InAppModalNotificationViewBinderFactory | This class is responsible for creating instances of InAppNotificationViewBinder for modal notifications. |
InAppBannerNotificationViewBinderFactory | This class is responsible for creating instances of InAppNotificationViewBinder for banner notifications. |
Styles | This class represents the style configuration for an in-app notification view. |
Enum |
WebexConnectAppDelegate
Methods | Description |
---|---|
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
Methods | Description |
---|---|
requestNotificationPermission | Requests 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. |
setAppDelegateMethodSwizzlingEnabled | This method enables/disables method swizzling for application life cycle methods and remote notifications methods based on isEnabled parameter value. |
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. |
isConnectPushMessage | Checks 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
Methods | Description |
---|---|
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
Methods | Description |
---|---|
didUpdatePushToken(_:type) | Notifies the delegate when the device token is updated. |
PushMessagingDelegate Protocol
Methods | Description |
---|---|
didReceiveMessage(message:fromTap:) | This method notifies the delegate when a push message is received. |
PushActionsDelegate Protocol
Methods | Description |
---|---|
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
Methods | Description |
---|---|
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
Methods | Description |
---|---|
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
Methods | Description |
---|---|
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
Methods | Description |
---|---|
createNotificationView() | Creates a new instance of InAppNotificationViewBinder for modal notifications. |
InAppBannerNotificationViewBinderFactory
Methods | Description |
---|---|
createNotificationView() | Creates a new instance of InAppNotificationViewBinder for banner notifications. |
Styles
Styles | Description |
---|---|
InAppNotificationViewStyle | This class represents the style configuration for an in-app notification view. |
InAppNotificationButtonStyle | This class represents the style configuration for a button in an in-app notification. |
InAppBannerNotificationViewStyle | This class represents the style configuration for a banner notification view, which is a subclass of InAppNotificationViewStyle. |
InAppModalNotificationViewStyle | 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. |
Enums
Enumeration | Description |
---|---|
InAppNotificationTheme | This enumeration defines the themes available for in-app notifications: dark and light. |
PushMessageStatus | This enumeration represents the status of a push message. |
PushDisplayType | This enumeration represents the display type of a push message. |
PushTokenType | This 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 Name | Description |
---|---|
instance | The 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 Name | Type | Description |
---|---|---|
application | UIApplication | The 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 Name | Type | Description |
---|---|---|
application | UIApplication | The singleton app object. |
deviceToken | Data | A 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 Name | Type | Description |
---|---|---|
application | UIApplication | The singleton app object. |
error | Error | The 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 Name | Type | Description |
---|---|---|
application | UIApplication | The singleton app object. |
userInfo | [AnyHashable : Any] | A dictionary that contains information related to the remote notification. |
completionHandler | @escaping (UIBackgroundFetchResult) -> Void | The 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 Name | Type | Description |
---|---|---|
notification | UNNotification | The notification object being presented. |
completionHandler | @escaping (UNNotificationPresentationOptions) -> Void | The 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 Name | Type | Description |
---|---|---|
center | UNUserNotificationCenter | The notification center that received the notification. |
response | UNNotificationResponse | The user's response to the notification. |
completionHandler | @escaping () -> Void | The block to execute when the user's response handling is complete. |
PushMessage
PushMessage is a structure that represents a push message.
Properties
Property Name | Description |
---|---|
message | The actual message of the push notification. |
extras | Any additional data associated with the push message. |
customTags | Any custom tags associated with the push message. |
readAt | The date when the push message was read. |
createdAt | The date when the push message was created. |
submittedAt | The date when the push message was submitted. |
deliveredAt | The date when the push message was delivered. |
transactionId | The transaction ID of the push message. |
status | The status of the push message. |
title | The title of the push message. |
category | The category of the push message. |
displayOptions | The display options for the push message. |
thread | The thread object associated with the push message. |
PushDisplayOptions
A class represents display options of a push message.
Properties
Name | Return Type | Description |
---|---|---|
isExpandable | Bool | Boolean value indicating whether the push message is expandable. |
type | PushDisplayType | The type of display for the push message. |
PushInteractiveData
A class represents the Push interactive data.
Properties
Name | Return Type | Description |
---|---|---|
action | String | The action of the push interactive data. |
category | String | The category of the push interactive data. |
identifier | String | The identifier of the push interactive data. |
value | String | The 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:
Parameter | Type | Description |
---|---|---|
identifier | String | The identifier of the interactive data. |
category | String | The category of the interactive data. |
action | String | The action of the interactive data. |
value | String | The value of the interactive data. |
PushMessaging Protocol
Protocol defining the basic structure for push notification handling.
Properties
Property Name | Description |
---|---|
actionsDelegate | Delegate responsible for handling push notification actions. |
pushMessagingDelegate | Delegate responsible for handling push messaging. |
pushTokenDelegate | Delegate responsible for updating the device token. |
additionalAuthorizationOptions | Additional authorization options to request when registering for push notifications. |
fcmPushProvider | Provides Firebase Cloud Messaging push services. |
apnsToken | The APNS token received from Apple Push Notification Service (APNS) registration. |
fcmToken | The FCM token received from Firebase Cloud Messaging (FCM) registration. |
notificationCategories | Categories for push notifications. |
foregroundNotificationPresentationOptions | The presentation options for notifications when the app is in the foreground. |
inAppNotificationManager | An instance for managing in-app notifications. |
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 tofalse
in the Configuration plist. IfshouldRequestNotificationPermission
istrue
, this method is automatically invoked after user registration.
Sample Code:
let push = PushMessagingProvider.instance
push.requestNotificationPermission()
id<PushMessaging> push = [PushMessagingProvider instance];
[push 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 Name | Type | Description |
---|---|---|
token | String | A String representing the device token received from the push notification service. |
type | PushTokenType | The PushTokenType indicating whether the token is for APNS or FCM. |
completionHandler | (Error?) -> Void | A closure of type (Error?) -> Void that is called when the operation is complete. This closure contains an optional error. |
Sample Code:
let push = PushMessagingProvider.instance
push.processPushToken("apnsToken", type: .apns) { error in
if error == nil {
print("Token posted successfully")
} else {
print("Error while processing push token: \(error!.localizedDescription)")
}
}
id<PushMessaging> push = [PushMessagingProvider instance];
[push processPushToken:@"apnstoken" type:PushTokenTypeApns completionHandler:^(NSError * error) {
if (error == nil) {
NSLog(@"Token posted successfully ");
} else {
NSLog(@"Error while processing push token : %@", error)
}
}];
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
Parameter | Type | Description |
---|---|---|
isEnabled | Bool | A boolean value indicating whether to enable (true ) or disable (false ) method swizzling. |
Sample Code:
let push = PushMessagingProvider.instance
push.setAppDelegateMethodSwizzlingEnabled(true)
id<PushMessaging> push = [PushMessagingProvider instance];
[push setAppDelegateMethodSwizzlingEnabled:true];
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
Parameter | Type | Description |
---|---|---|
isEnabled | Bool | A boolean value indicating whether to set (true ) or ignore (false ) User Notification Center Delegate. |
Sample Code:
let push = PushMessagingProvider.instance
push.setNotificationCenterMethodSwizzlingEnabled (true)
id<PushMessaging> push = [PushMessagingProvider instance];
[push setNotificationCenterMethodSwizzlingEnabled:true];
isConnectPushMessage
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
Parameter | Type | Description |
---|---|---|
userInfo | [String: Any] | The dictionary containing push notification information. |
Sample Code:
let push = PushMessagingProvider.instance
push.isConnectPushMessage (userInfo: ["message" : "test"])
id<PushMessaging> push = [PushMessagingProvider instance];
[push isConnectPushMessageWithUserInfo:@{ "message" : "test"}];
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
Parameter | Type | Description |
---|---|---|
transIds | The transaction IDs of the messages. | |
status | The status of the message either delivered or read. | |
completionHandler: | The function to call when the operation is complete. |
Sample Code:
let push = PushMessagingProvider.instance
push.sendMessageStatus(forTransIds: ["transId"], status: .delivered) { error in
//Handle error
}
id<PushMessaging> push = [PushMessagingProvider instance];
[push sendMessageStatusForTransIds:@[@"transId"] status:PushMessageStatusDelivered completionHandler:^(NSError * error) {
//Handle error
}];
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
Parameter | Type | Description |
---|---|---|
transId | String | The transaction ID whose status is to be sent. |
status | PushMessageStatus | The status of the message. |
interactiveData | PushInteractiveData | The 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:
let push = PushMessagingProvider.instance
push.sendMessageStatus(forTransId: "transId", status: .delivered, interactiveData:nil) { error in
//Handle error
}
id<PushMessaging> push = [PushMessagingProvider instance];
[push sendMessageStatusForTransId:@"transId" status:PushMessageStatusDelivered interactiveData:nil completionHandler:^(NSError * error) {
//Handle error
}];
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 Name | Type | Description |
---|---|---|
topic | String | The topic to subscribe to. |
completionHandler | (Error?) -> Void | A 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 Name | Type | Description |
---|---|---|
topic | String | The 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 | Type | Description |
---|---|---|
data | Data | The APNS token in Data format, typically obtained from didRegisterForRemoteNotificationsWithDeviceToken |
completionHandler | (String?, Error?) -> Void | A 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 Name | Type | Description |
---|---|---|
pushToken | String | The updated push token received from the push provider. |
type | PushTokenType | The 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 Name | Type | Description |
---|---|---|
message | PushMessage | The data representing the received push message. |
fromTap | Bool | A 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 Name | Type | Description |
---|---|---|
action | String | The action string that identifies what action the user took. |
identifier | String | The identifier of the action that was taken by the user. |
message | PushMessage | The 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(message:)
This method will be invoked when InApp Notification is displayed.
Syntax: func onNotificationDisplayed(message: PushMessage?)
Parameters
Parameter Name | Type | Description |
---|---|---|
message | PushMessage? | The received PushMessage. |
onNotificationClicked(message: action: value:)
This method will be invoked when InApp Notification action is clicked.
Syntax: func onNotificationClicked(message: PushMessage?, action: String?, value: String?)
Parameters
Parameter Name | Type | Description |
---|---|---|
message | PushMessage? | The received PushMessage. |
action | String? | Action to perform when interaction takes place. |
value | String? | Value used to complete certain actions. |
onNotificationDismissed(message:)
This method will be invoked when InApp Notification is dismissed.
Syntax: func onNotificationDismissed(message: PushMessage?)
Parameters
Parameter Name | Type | Description |
---|---|---|
message | PushMessage? | The received PushMessage. |
InAppNotificationManager Protocol
The InAppNotificationManager protocol defines the interface for managing in-app notifications. It extends the NSObject class.
Properties
Property Name | Description |
---|---|
inAppdelegate | The 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 Name | Type | Description |
---|---|---|
notificationFactory | InAppNotificationViewBinderFactory | An 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 Name | Type | Description |
---|---|---|
message | PushMessage | The 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 Name | Description |
---|---|
pushMessage | The push message associated with the notification. |
delegate | The 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 Name | Type | Description |
---|---|---|
message | PushMessage | The push message to be bound to the view. |
setViewStyle(_:)
Sets the visual style of the notification view.
Syntax: func setViewStyle(_ style: InAppNotificationViewStyle)
Parameters
Parameter Name | Type | Description |
---|---|---|
style | InAppNotificationViewStyle | The visual style to be applied to the view. |
setTheme(_:)
Sets the theme of the notification view.
Syntax: func setTheme(_ theme: InAppNotificationTheme)
Parameters
Parameter Name | Type | Description |
---|---|---|
theme | InAppNotificationTheme | The theme to be applied to the view. |
getView()
Retrieves the view controller associated with the notification view.
Syntax: func getView() -> UIViewController
Parameters
Return Type | Description |
---|---|
UIViewController | The 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 Name | Description |
---|---|
notificationType | Indicates the type of the message part handled by the factory. |
Methods
Method Name | Description |
---|---|
createNotificationView() | Creates a new InAppNotificationViewBinder instance. |
createNotificationView()
Creates a new InAppNotificationViewBinder instance.
Syntax: public func createNotificationView() -> InAppNotificationViewBinder
Parameters
Return Type | Description |
---|---|
InAppNotificationViewBinder | A new instance of InAppNotificationViewBinder. |
InAppNotificationViewBinderDelegate Protocol
A delegate protocol for handling in-app notification events.
Methods
Method Name | Description |
---|---|
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
Parameter | Description |
---|---|
message | The 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
Parameter | Type | Description |
---|---|---|
message | PushMessage | The received PushMessage object. |
action | String | The received action type as a String. |
value | String | The received value as a String. |
onNotificationDismiss(_:)
Invoked whenever an in-app notification is dismissed.
Syntax: func onNotificationDismissed(_ message: PushMessage)
Parameters
Parameter | Description |
---|---|
message | The received PushMessage object. |
InAppNotificationModalViewBinderFactory
This class is responsible for creating instances of InAppNotificationViewBinder for modal notifications.
Properties:
Property Name | Description |
---|---|
notificationType | Indicates 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 Name | Description |
---|---|
notificationType | Indicates 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 Name | Description |
---|---|
titleTextColor | The text color for the notification title label. |
titleTextFont | The text font for the notification title label. |
titleTextShadowColor | The shadow color for the notification title label text. |
textColor | The text color for the notification details label. |
textFont | The text font for the notification details label. |
textShadowColor | The shadow color for the notification details label text. |
backgroundColor | The background color for the notification view. |
buttonStyle | The 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 Name | Description |
---|---|
buttonTextColor | The text color for the notification button. |
buttonTintColor | The tint color for the notification button. |
buttonType | The type of the notification button. |
buttonBackgroundColor | The 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 Name | Description |
---|---|
closeButtonTintColor | The tint color for the close button of the banner notification. |
closeButtonBackgroundColor | The background color for the close button of the banner notification. |
closeButtonImage | The 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 Name | Type | Description |
---|---|---|
darkThemeStyle | Bool | A 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 Name | Type | Description |
---|---|---|
lightThemeStyle | Bool | A 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 Name | Type | Description |
---|---|---|
darkThemeStyle | Bool | A 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 Name | Type | Description |
---|---|---|
lightThemeStyle | Bool | A 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.
Value | Description |
---|---|
dark | Represents the dark theme for in-app notifications. |
light | Represents the light theme for in-app notifications. |
PushMessageStatus
This enumeration represents the status of a push message.
Value | Description |
---|---|
delivered | Represents a case where the push message has been delivered. |
read | Represents a case where the push message has been read. |
PushDisplayType
This enumeration represents the display type of a push message.
Value | Description |
---|---|
none | Represents a case where the display type of a push message is not defined. |
banner | Represents a case where the push message is displayed as a banner. |
modal | Represents 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.
Value | Description |
---|---|
apns | Represents the Apple Push Notification service (APNS) token type used for delivering notifications to iOS devices. |
fcm | Represents the Firebase Cloud Messaging (FCM) token type used for delivering notifications to iOS devices. |
Updated about 1 month ago