MoEngageSDKMessaging
@objc
public class MoEngageSDKMessaging : NSObject
Class responsible for Push integration
-
Singleton instance
Declaration
Swift
@objc public static let sharedInstance: MoEngageSDKMessaging
-
Requests the user’s authorization to allow local and remote notifications for your app.
Declaration
Swift
@available(tvOS, unavailable) @available(iOSApplicationExtension, unavailable) @discardableResult @objc public func registerForRemoteNotification( withCategories categories: Set<UNNotificationCategory>? = nil, andUserNotificationCenterDelegate delegate: UNUserNotificationCenterDelegate? = nil ) -> MoEngagePushTokenTaskParameters
categoriesA type of notification your app supports and the custom actions that the system displays.
delegateThe interface for handling incoming notifications and notification-related actions.
Return Value
MoEngagePushTokenTaskresolving once the registration request has been issued to the OS. APNs-side success/failure (token delivery, permission grant) is delivered separately viaMoEngageMessagingDelegate. -
Method to register for provisional push permission.
Declaration
Swift
@available(iOS 12.0, *) @available(tvOS, unavailable) @discardableResult @objc public func registerForRemoteProvisionalNotification( withCategories categories: Set<UNNotificationCategory>? = nil, andUserNotificationCenterDelegate delegate: UNUserNotificationCenterDelegate? = nil ) -> MoEngagePushTokenTaskParameters
categoriesA type of notification your app supports and the custom actions that the system displays.
delegateThe interface for handling incoming notifications and notification-related actions.
Return Value
MoEngagePushTokenTask— same contract asregisterForRemoteNotification(...). -
Method to add the notification categories to the existing list of
MOE_DISMISS_CATEGORYandMOE_PUSH_TEMPLATEcategory.Declaration
Swift
@available(tvOS, unavailable) @discardableResult @objc public func setUserNotificationCategories(_ categories: Set<UNNotificationCategory>? = nil) -> MoEngagePushTokenTaskParameters
categoriesSet of categories.
Return Value
MoEngagePushTokenTaskresolving once the categories have been registered withUNUserNotificationCenter.
-
Set the delegate inorder to receive the notification related callbacks
Declaration
Swift
@available(tvOS, unavailable) @objc public func setMessagingDelegate(_ delegate: MoEngageMessagingDelegate?)Parameters
delegateInstance that conforms to
MoEngageMessagingDelegateprotocol. -
Set the delegate inorder to receive the notification related callbacksfor Secondary MoEngage Instance.
Declaration
Swift
@available(tvOS, unavailable) @objc public func setMessagingDelegate(_ delegate: MoEngageMessagingDelegate?, forAppID appID: String? = nil)Parameters
delegateInstance that conforms to
MoEngageMessagingDelegateprotocol.appIDMoEngage Account Identifier
-
In case you have disabled swizzling, call this method to pass the device token to MoEngage SDK.
Declaration
Swift
@available(iOSApplicationExtension, unavailable) @available(tvOS, unavailable) @discardableResult @objc public func setPushToken(_ deviceToken: Data?) -> MoEngagePushTokenTaskParameters
deviceTokenIdentifier for the Apple Push Notification System.
Return Value
MoEngagePushTokenTaskresolving once the token has been accepted into the SDK’s register pipeline. Rejects with.invalidPushTokenwhendeviceTokenisnilor empty. -
In case you have disabled swizzling, call this method when notification registration fails.
onSuccessfires once the SDK has accepted the register-failure signal — the task represents the outcome of this call, not the underlying APNs event.onFailurefires with.sdkNotInitializedif the SDK isn’t initialized yet.Declaration
Swift
@available(iOSApplicationExtension, unavailable) @available(tvOS, unavailable) @discardableResult @objc public func didFailToRegisterForPush() -> MoEngagePushTokenTask -
In case you have disabled swizzling, call this method on receiving the notification.
Stays
Void— framework-callback forwarder (customer plumbing OS events into the SDK), not an action API. Same out-of-scope category assetMessagingDelegate.Declaration
Swift
@available(iOSApplicationExtension, unavailable) @available(tvOS, unavailable) @objc public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification)Parameters
centerThe central object for managing notification-related activities for your app or app extension.
notificationThe data for a local or remote notification the system delivers to your app.
-
In case you have disabled swizzling, call this method on performing any action on the notification.
Stays
Void-returning: framework-callback forwarder (seeuserNotificationCenter(_:willPresent:)).Declaration
Swift
@available(iOSApplicationExtension, unavailable) @available(tvOS, unavailable) @objc public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse)Parameters
centerThe central object for managing notification-related activities for your app or app extension.
responseThe user’s response to an actionable notification.
-
Method to disable badge reset by SDK
Declaration
Swift
@available(tvOS, unavailable) @available(*, deprecated, message: "Use MoEngageBadgeUpdateEnabled key in Info.plist instead.") @objc public func disableBadgeReset(_ disable: Bool)Parameters
disablePass true to disable badge reset
-
Track notification received impression.
Declaration
Swift
@available(tvOS, unavailable) @discardableResult @objc public func logNotificationReceived(withPayload payload: [AnyHashable : Any]) -> MoEngageLogNotificationTaskParameters
payloadAPNS notification payload.
Return Value
MoEngageLogNotificationTaskresolving onSuccess after the impression is accepted into the local batch storage. Rejects with.duplicateImpressionif the same impression payload was already tracked in a prior call (dedup), or with.sdkNotInitializedwhen no SDK instance matches the payload’s workspace. -
Track notification received impression with a completion callback.
Deprecated. Use the typed-task-returning
logNotificationReceived(withPayload:)variant; attachonSuccessto be notified when the impression is logged.Declaration
Swift
@available(tvOS, unavailable) @available(*, deprecated, message: "Use the typed-task-returning logNotificationReceived(withPayload:﹚ variant; attach onSuccess to be notified when the impression is logged.") @objc public func logNotificationReceived(withPayload payload: [AnyHashable : Any], completion: @escaping () -> Void)Parameters
payloadAPNS notification payload.
completionCallback when notification received impression track completed.
-
Track notification click impression.
Declaration
Swift
@available(iOSApplicationExtension, unavailable) @available(tvOS, unavailable) @discardableResult @objc public func logNotificationClicked(withPayload payload: [AnyHashable : Any]) -> MoEngageLogNotificationTaskParameters
payloadAPNS notification payload.
Return Value
MoEngageLogNotificationTaskresolving once the click has been logged. For non-MoEngage payloads the task resolves with the echoed payload after the session-source-update side-effect (no click impression is logged for non-MoEngage pushes — matches the existing behaviour). -
Track notification click or dismiss based on the response.
Declaration
Swift
@available(iOSApplicationExtension, unavailable) @available(tvOS, unavailable) @discardableResult @objc public func logNotificationClicked(withResponse response: UNNotificationResponse) -> MoEngageLogNotificationTaskParameters
responseAPNS notification response.
Return Value
MoEngageLogNotificationTask— same contract as thewithPayloadvariant. -
Validate if the notification belongs to MoEngage.
Declaration
Swift
@available(tvOS, unavailable) @objc public func isPushFromMoEngage(withPayload payload: [AnyHashable : Any]) -> BoolParameters
payloadAPNS notification payload.
Return Value
trueif the notification belongs to MoEngage, elsefalse. -
Navigate to push permission settings page.
Declaration
Swift
@available(iOSApplicationExtension, unavailable) @discardableResult @objc public func navigateToPushSettings() -> MoEngageNavigationTaskReturn Value
MoEngageNavigationTaskresolving once the SDK has issued the open-Settings request. Does NOT confirm Settings actually opened on screen (UIApplication.open(_:)completes asynchronously). -
Checks if the push notification payload is a self-handled background notification. A self-handled background notification is a special type of notification that the app handles in the background without displaying it to the user.
Declaration
Swift
@objc public func isSelfHandledBackgroundNotification(payload: [AnyHashable : Any]) -> BoolParameters
payloadThe push notification payload dictionary.
Return Value
trueif the notification is a self-handled background notification (notification type is “sh_b”),falseotherwise.