Class
The main API class of PushFeature module
Declaration
@objc(SFPushFeature)
public final class PushFeature: NSObject,
SFMCModule,
Subscriber,
Publisher
@objc
public static func requestSdk(_ callback: @escaping (_ pushFeature: PushFeatureApi?) -> Void)
public func setDeviceToken(_ deviceToken: Data)
public func deviceToken() -> String?
public func setPushEnabled(pushEnabled: Bool)
public func isPushEnabled() -> Bool
public func setNotificationResponse(_ response: UNNotificationResponse)
public func notificationResponse() -> UNNotificationResponse?
public func setNotificationUserInfo(_ userInfo: [AnyHashable : Any])
public func notificationUserInfo() -> [AnyHashable : Any]
public func setURLHandlingDelegate(_ delegate: URLHandlingDelegate)
Request SDK Method
requestSdk(_:)
Requests the Push Feature Module when it’s operational and safe to use. The provided callback will be invoked with the Push Feature Module when it’s ready. All push feature module-related API calls should be made within this function.
@objc
public static func requestSdk(_ callback: @escaping (_ pushFeature: PushFeatureApi?) -> Void)
Push Token Methods
setDeviceToken(_:)
Responsible for sending the Apple device token back to all the subscribers. It marks the end of the token registration flow. If it is unable to reach Salesforce server, it will save the token and try again later. This method is necessary to the implementation of Salesforce Push.
public func setDeviceToken(_ deviceToken: Data)
deviceToken()
Returns the device token as a String.
public func deviceToken() -> String?
Feature Toggle Methods
setPushEnabled(pushEnabled:)
Developer override to set the state of push enablement to true/false. If set to false, the application will not receive any push notifications once the Marketing Cloud server has been updated. When this value is false, it takes precedence (overrides) the user notifications settings (i.e., setting this to false will always disable push.) Conversely, if the user has notifications settings disabled, the developer cannot enable push via this method. A false value from either source (user settings or developer interface) always wins.
public func setPushEnabled(pushEnabled: Bool)
isPushEnabled()
Combination of push enabled from user notifications settings and push enabled by sdk.
public func isPushEnabled() -> Bool
PushNotification Methods
setNotificationResponse(_:)
Informs the module of the current notification response when user clicks a notification.
public func setNotificationResponse(_ response: UNNotificationResponse)
notificationResponse()
Returns the last notification response delivered to the module.
public func notificationResponse() -> UNNotificationResponse?
setNotificationUserInfo(_:)
Informs the module of the current userInfo when user clicks a notification.
public func setNotificationUserInfo(_ userInfo: [AnyHashable : Any])
notificationUserInfo()
Returns the user info of the last notification delivered to the module.
public func notificationUserInfo() -> [AnyHashable : Any]
URLHandling
setURLHandlingDelegate(_:)
Set URLHandling delegate to handle URLs in OpenDirect URLs, CloudPage URLs, CloudPage URLs from inbox messages.This value takes precedence over the config setting which is passed during the SDK initialization.
public func setURLHandlingDelegate(_ delegate: URLHandlingDelegate)