PushModule

@objc(SFMCSdkPushModule)
public final class PushModule : NSObject, SFMCModule, PushInterface, Subscriber, Publisher

This class is a Swift Interface for SFMCSdkPushModule

  • Enum to get the Module Name

    Declaration

    Swift

    public var name: ModuleName
  • String to get the Module Version

    Declaration

    Swift

    public static var moduleVersion: String
  • Dictionary to get the SDK properties

    Declaration

    Swift

    public static var stateProperties: [String : String]?
  • Enum to get the status of Module with options => .inactive, .cancelled, .disabled, .failed, .initializing, .operational

    Declaration

    Swift

    @objc
    public static var status: ModuleStatus
  • Singleton interface to access the PushModule

    Declaration

    Swift

    @objc
    public static var shared: PushModule { get }
  • Unified Logger initialized for ‘Push’ Module Usage: logger.d(category: .event, message: “Message”) Category : Enum with following values => auth, behavior, encryption, eventBus, network, module, sdk, storage, consent, coredata, database, event, identity, interface, location, session, util

    Declaration

    Swift

    @objc
    public static let logger: ModuleLogger
  • Unified Logger initialized for ‘Push’ Module

    Usage Example:

    PushModule.shared.getLogger().d(category: .event, message: “Message”)

    Declaration

    Swift

    @objc
    public static func getLogger() -> ModuleLogger
  • This method is used to get the SDK identity attributes such as applicationId, customProperties, installationId, profileId

    Declaration

    Swift

    public func getIdentity() -> ModuleIdentity?
  • This method is used to receive message from publishers and update the identities like profile atributes and contactKey

    Declaration

    Swift

    public func receive(message: Message)

    Parameters

    message

    SFMCEvent, publish to specific Custom event

  • This method is used to publish to a custom event, SFMCEvent

    Declaration

    Swift

    @objc
    public static func sendSfmcEvent(_ event: SFMCEvent, category: EventCategory)

    Parameters

    event

    SFMCEvent, publish to specific Custom event

    category

    EventCategory, category which falls under any one of the category 1) .engagemnt, 2) .identity, 3) .system

  • This method is to listen to specific tags set by the consuming application

    Declaration

    Swift

    @objc
    public static func sendIdentityEventForTags()
  • This method is to listen to contactkey set by the consuming application

    Declaration

    Swift

    @objc
    public static func sendIdentityEventForContactKey()
  • This method is to listen to attributes set by the consuming application

    Declaration

    Swift

    @objc
    public static func sendIdentityEventForAttributes()
  • This method is to get the SDK metadata

    Declaration

    Swift

    @objc
    public static func metadata() -> [String : Any]
  • This method properly closes down the MarketingCloudSDK. It should be used in any cases where references to the MarketingCloudSDK need to be released. Only call when SDK is operational. Eg: if(SFMCSdk.mp.getStatus() == .operational) { SFMCSdk.mp.tearDown()}

    Note

    This method will be removed in future versions.

    Declaration

    Swift

    @available(*, deprecated, message: "This method will be removed as the Push Module will automatically handle tear downs upon initializations")
    public func tearDown()
  • Returns the contact key for the active user, in case you need it.

    Declaration

    Swift

    public func contactKey() -> String?

    Return Value

    Contact key String that is set in the application.

  • Adds the provided Tag (NSString) to the set of unique tags.

    Declaration

    Swift

    public func addTag(_ tag: String) -> Bool

    Parameters

    tag

    A string to add to the list of tags.

    Return Value

    YES if added successfully.

  • Adds the provided array of Tags (NSString) to the set of unique tags. Will trim leading and trailing whitespace. Cannot be nil or blank.

    Declaration

    Swift

    public func addTags(_ tags: [Any]) -> Set<AnyHashable>?

    Parameters

    tags

    An array of tags to add to the list.

    Return Value

    Set of tags added, as strings, or nil if something failed.

  • Removes the provided Tag (NSString) from the list of tags.

    Declaration

    Swift

    public func removeTag(_ tag: String) -> Bool

    Parameters

    tag

    A string to remove from the list of tags.

    Return Value

    YES if removed successfully.

  • Returns the list of tags for this device.

    Declaration

    Swift

    public func tags() -> Set<AnyHashable>?

    Return Value

    All tags associated, as strings.

  • Responsible for sending the Apple device token back to Salesforce. 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.

    Declaration

    Swift

    public func setDeviceToken(_ deviceToken: Data)

    Parameters

    deviceToken

    An array of tags to add to the list.

  • Enable/Disable extra debug logging from the SDK.

    Declaration

    Swift

    public func setDebugLoggingEnabled(_ enabled: Bool)

    Parameters

    enabled

    BOOL for enabling or disabling extra SDK logging.

  • Returns the device token as a NSString.

    Declaration

    Swift

    public func deviceToken() -> String?
  • Returns a read-only copy of the Attributes dictionary as it is right now.

    Declaration

    Swift

    public func attributes() -> [AnyHashable : Any]?
  • Returns the Salesforce application accessToken.

    Declaration

    Swift

    public func accessToken() -> String?
  • Returns the unique device identifier that Salesforce will use to identify the device.

    Declaration

    Swift

    public func deviceIdentifier() -> String?
  • Informs the SDK of the current notification.

    Declaration

    Swift

    public func setNotificationRequest(_ request: UNNotificationRequest)
  • Returns the last notification delivered to the SDK.

    Declaration

    Swift

    public func notificationRequest() -> UNNotificationRequest?
  • Informs the SDK of the current notification.

    Declaration

    Swift

    public func setNotificationUserInfo(_ userInfo: [AnyHashable : Any])

    Parameters

    userInfo

    The user info the last notification delivered to the SDK.

  • Returns the user info of the last notification delivered to the SDK.

       @return NSDictionary * The user info the last notification delivered to the SDK.
    

    Declaration

    Swift

    public func notificationUserInfo() -> [AnyHashable : Any]
  • Developer override to set the state of push enablement to YES/NO. If set to NO, the application will not receive any push notifications once the Marketing Cloud server has been updated. When this value is NO, it takes precedence (overrides) the user notifications settings (i.e., setting this to NO will always disable push.) Conversely, if the user has notifications settings disabled, the developer cannot enable push via this method. A NO value from either source (user settings or developer interface) always wins.

    Declaration

    Swift

    public func setPushEnabled(_ pushEnabled: Bool)

    Parameters

    pushEnabled

    Set to YES to enable push notifications.

  • The current state of the developer’s push enablement override The current state of the pushEnabled flag in the SDK.

    Declaration

    Swift

    public func pushEnabled() -> Bool
  • Ask MarketingCloudSDK to update its data. MarketingCloudSDK will throttle attempts based on the time since the last time this was called.

    Declaration

    Swift

    public func refresh(fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)?) -> Bool

    Parameters

    completionHandler

    The UIBackgroundFetchResult completion handler. This method will be called with UIBackgroundFetchResultNoData if no attempt was made to update data, otherwise it will be called with UIBackgroundFetchResultNewData after the update completes. If nil is passed, then process of the completion handler must be managed by the caller.

  • Add a signedString security token for registration security

    Declaration

    Swift

    public func setSignedString(_ signedString: String?) -> Bool

    Parameters

    signedString

    signedString opaque token used to verify registration. pass nil to clear signedString.

  • Register a callback that will be notified when Registration related events happen

    @see: https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/sdk-implementation/user-data.html

    @param registrationCallback closure to be provided when registration event occurs

    Declaration

    Swift

    public func setRegistrationCallback(_ registrationCallback: @escaping (Dictionary<AnyHashable, Any>) -> Void)
  • Declaration

    Swift

    public func unsetRegistrationCallback()
  • Returns the value of last stored signedString security token

    Declaration

    Swift

    public func signedString() -> String?
  • In-app messages is used to deliver relevant, personalized messages to the app’s users with in-app messaging without relying on users having enabled push notifications. Set inapp message delegate

    Declaration

    Swift

    public func setEventDelegate(_ delegate: InAppMessageEventDelegate?)
  • Message Id for a given message dictionary

    Declaration

    Swift

    public func messageId(forMessage: [AnyHashable : Any]) -> String?

    Parameters

    forMessage

    Message Dictionary

  • Show in-app message in the app

    Declaration

    Swift

    public func showInAppMessage(messageId: String)

    Parameters

    messageId

    MessageId Id of the in-app message to be shown

  • Set in-app message to be shown in the app with specified font

    Declaration

    Swift

    public func setInAppMessage(fontName: String?) -> Bool

    Parameters

    fontName

    Fontname in which the app should be set

  • Returns an array of all messages that includes read, unread , deleted messages

    Public properties in inbox message dictionary

    Declaration

    Swift

    public func getAllMessages() -> [Any]?

    Return Value

    an Array of Dictionary containing all messages (read, unread and deleted)

  • Returns an array of unread messages

    Public properties in inbox message dictionary

    Declaration

    Swift

    public func getUnreadMessages() -> [Any]?
  • Returns an array of read messages

    Public properties in inbox message dictionary

    Declaration

    Swift

    public func getReadMessages() -> [Any]?
  • Returns an array of deleted messages

    Public properties in inbox message dictionary

    Declaration

    Swift

    public func getDeletedMessages() -> [Any]?
  • Returns all messages count

    Declaration

    Swift

    public func getAllMessagesCount() -> UInt
  • Returns unread messages count

    Declaration

    Swift

    public func getUnreadMessagesCount() -> UInt
  • Returns read messages count

    Declaration

    Swift

    public func getReadMessagesCount() -> UInt
  • Returns deleted messages count

    Declaration

    Swift

    public func getDeletedMessagesCount() -> UInt
  • Mark the unread messages as read

    Declaration

    Swift

    public func markMessageRead(_ messageDictionary: [AnyHashable : Any]) -> Bool
  • Mark the messages as deleted

    Declaration

    Swift

    public func markMessageDeleted(_ messageDictionary: [AnyHashable : Any]) -> Bool

    Parameters

    messageDictionary

    Collection of messages to be marked as deleted

  • Mark the message with specific messageId as read

    Declaration

    Swift

    public func markMessageWithIdRead(messageId: String) -> Bool

    Parameters

    messageId

    String Message with messageId String to be marked as read

  • Mark the message with specific messageId as deleted

    Declaration

    Swift

    public func markMessageWithIdDeleted(messageId: String) -> Bool

    Parameters

    messageId

    String Message with messageId String to be marked as deleted

  • Mark all the messages with specific messageId as read

    Declaration

    Swift

    public func markAllMessagesRead() -> Bool
  • Mark all the messages with specific messageId as deleted

    Declaration

    Swift

    public func markAllMessagesDeleted() -> Bool
  • Fetches and refreshes messages from server

    Declaration

    Swift

    public func refreshMessages() -> Bool
  • Set datasource for the inbox tableview

    Declaration

    Swift

    public func inboxMessagesTableViewDataSourceFor(tableView: UITableView) -> InboxMessagesDataSource?

    Parameters

    tableView

    Tableview for which datasource should be set

  • Set delegate for the inbox tableview

    Declaration

    Swift

    public func inboxMessagesTableViewDelegateFor(tableView: UITableView, dataSource: InboxMessagesDataSource) -> InboxMessagesDelegate?
  • Set String identifier

    Declaration

    Swift

    public func setPiIdentifier(_ identifier: String?) -> Bool

    Parameters

    identifier

    Identifier to be set

  • Returns piIdentifier

    Declaration

    Swift

    public func piIdentifier() -> String?
  • Track the inbox messages that are opened in the app

    Declaration

    Swift

    public func trackMessageOpened(_ inboxMessage: [AnyHashable : Any])

    Parameters

    inboxMessage

    Dictionary for which the track should happen

  • Track the pageview visited in the page

    Declaration

    Swift

    public func trackPageView(url: String, title: String?, item: String?, search: String?)

    Parameters

    url

    url String

    title

    Title of the pageview

    item

    item String

    search

    search String

  • Track contents in the cart

    Declaration

    Swift

    public func trackCartContents(_ cartDictionary: [AnyHashable : Any])

    Parameters

    cartDictionary

    Collection of items to be tracked

  • Track Conversion on the items in the cart

    Declaration

    Swift

    public func trackCartConversion(_ orderDictionary: [AnyHashable : Any])

    Parameters

    orderDictionary

    Collection of items converted in the bag

  • Returns cartItem Dictionary with specific price, quantity, item and Id

    Declaration

    Swift

    public func cartItemDictionary(price: NSNumber, quantity: NSNumber, item: String, uniqueId: String?) -> [AnyHashable : Any]?

    Parameters

    quantity

    car item Dictionary should be returned by quantity

    item

    item by which the car item Dictionary should be returned

    uniqueId

    Unique Id by which the car item Dictionary should be returned

  • Returns cart Dictionary with cartItem

    Declaration

    Swift

    public func cartDictionary(cartItem: [Any]) -> [AnyHashable : Any]?

    Parameters

    cartItem

    Collection of cartItems

  • Returns order Dictionary with ordernumber, shipping number, discount, cart dictionary

    Declaration

    Swift

    public func orderDictionary(orderNumber: String, shipping: NSNumber, discount: NSNumber, cart: [AnyHashable : Any]) -> [AnyHashable : Any]?

    Parameters

    orderNumber

    Order Dictionary returned by orderNumber

  • Set location delegate

    Declaration

    Swift

    public func setLocationDelegate(_ delegate: LocationDelegate?)

    Parameters

    delegate

    Location delegate

  • Returns region from collection of region

    Declaration

    Swift

    public func regionFrom(dictionary: [AnyHashable : Any]) -> CLRegion?

    Parameters

    dictionary

    Collection of region

  • Returns if location is enabled in the SDK

    Declaration

    Swift

    public func locationEnabled() -> Bool
  • Enables the co-ordinates tracking on the device

    Declaration

    Swift

    public func startWatchingLocation()
  • Disables the co-ordinates tracking on the device

    Declaration

    Swift

    public func stopWatchingLocation()
  • Returns if location watching is enabled or not

    Declaration

    Swift

    public func watchingLocation() -> Bool
  • Returns last known location

    Declaration

    Swift

    public func lastKnownLocation() -> [String : String]?
  • Set URLHandling delegate to handle URLs in OpenDirect URLs, CloudPage URLs, CloudPage URLs from inbox messages

    Declaration

    Swift

    public func setURLHandlingDelegate(_ delegate: URLHandlingDelegate?)

    Parameters

    delegate

    set the delegate to handle URLs

  • Initialize PushModule and return Shared instance

    Declaration

    Swift

    public static func initModule(config: ModuleConfig, components: SFMCSdkComponents) -> SFMCModule?

    Parameters

    config

    Module config with module name and appid

    components

    EncryptionManager, StorageManager, BehaviourManager

  • Returns if Data merge policy is reset to re-trigger merge

    Declaration

    Swift

    public func resetDataPolicy() -> Bool