MobilePushSDK

Objective-C

@interface MobilePushSDK : NSObject

Swift

class MobilePushSDK : NSObject

The MarketingCloudSDK base class and categories

  • Unavailable

    UNAVAILABLE - please use the sharedInstance class method to get an instance of the SDK

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Returns (or initializes) the shared MarketingCloudSDK instance.

    Declaration

    Objective-C

    + (nonnull instancetype)sharedInstance;

    Swift

    class func sharedInstance() -> Self

    Return Value

    The singleton instance of the MarketingCloudSDK.

  • This is the main configuration method, responsible for setting credentials needed to communicate with Salesforce. You must pass in the NSDictionary created by the MarketingCloudSDKConfigBuilder sfmc_build method. Use the MarketingCloudSDKConfigBuilder class to specify the configuration parameter settings needed by your project. Settings that are absent will default to NO. The following example shows how you can use the MarketingCloudSDKConfigBuilder class to create the configuration dictionary.

    MarketingCloudSDKConfigBuilder *mcsdkBuilder = [MarketingCloudSDKConfigBuilder new];
    [mcsdkBuilder sfmc_setApplicationId:@"93783629-08C7-48D3-8482-3E5BC8DBA888"];
    [mcsdkBuilder sfmc_setAccessToken:@"xyzymn5gb7y2z3wph3t4yxyz"];
    [mcsdkBuilder sfmc_setInboxEnabled:@(YES)];
    [mcsdkBuilder sfmc_setLocationEnabled:@(YES)];
    [mcsdkBuilder sfmc_setAnalyticsEnabled:@(YES)];
    [mcsdkBuilder sfmc_setPiAnalyticsEnabled:@(YES)];
    [mcsdkBuilder sfmc_setMid:@"1234567"];
    [mcsdkBuilder sfmc_setMarketingCloudServerUrl:@"https://consumer.exacttargetapis.com"];
    
    NSError *error = nil;
    BOOL success = [[MarketingCloudSDK sharedInstance] sfmc_configureWithDictionary:[mcsdkBuilder sfmc_build] error:&error];
    

    Declaration

    Objective-C

    - (BOOL)sfmc_configureWithDictionary:(nonnull NSDictionary *)configuration
                                   error:(NSError *_Nullable *_Nullable)error;

    Swift

    func sfmc_configure(with configuration: [AnyHashable : Any]) throws

    Parameters

    configuration

    NSDictionary created by the MarketingCloudSDKConfigBuilder class

    error

    NSError object describing the error.

    Return Value

    Returns YES if the configuration is successful or NO if failed. Do not proceed if NO is returned and error will contain an error object describing the error. The configuration is synchronously performed and will block the calling thread.

  • This is the main configuration method, responsible for setting credentials needed to communicate with Salesforce. You must pass in the NSDictionary created by the MarketingCloudSDKConfigBuilder sfmc_build method. Use the MarketingCloudSDKConfigBuilder class to specify the configuration parameter settings needed by your project. Settings that are absent will default to NO. The following example shows how you can use the MarketingCloudSDKConfigBuilder class to create the configuration dictionary.

    MarketingCloudSDKConfigBuilder *mcsdkBuilder = [MarketingCloudSDKConfigBuilder new];
    [mcsdkBuilder sfmc_setApplicationId:@"93783629-08C7-48D3-8482-3E5BC8DBA888"];
    [mcsdkBuilder sfmc_setAccessToken:@"xyzymn5gb7y2z3wph3t4yxyz"];
    [mcsdkBuilder sfmc_setInboxEnabled:@(YES)];
    [mcsdkBuilder sfmc_setLocationEnabled:@(YES)];
    [mcsdkBuilder sfmc_setAnalyticsEnabled:@(YES)];
    [mcsdkBuilder sfmc_setPiAnalyticsEnabled:@(YES)];
    [mcsdkBuilder sfmc_setMid:@"1234567"];
    [mcsdkBuilder sfmc_setMarketingCloudServerUrl:@"https://consumer.exacttargetapis.com"];
    
    NSError *error = nil;
    BOOL success = [[MarketingCloudSDK sharedInstance] sfmc_configureWithDictionary:[mcsdkBuilder sfmc_build] error:&error completionHandler:^(BOOL success, NSString *appid, NSError *error) {}];
    

    Declaration

    Objective-C

    - (BOOL)sfmc_configureWithDictionary:(nonnull NSDictionary *)configuration
                                   error:(NSError *_Nullable *_Nullable)error
                       completionHandler:
                           (void (^_Nullable)(BOOL, NSString *_Nonnull,
                                              NSError *_Nonnull))completionHandler;

    Swift

    func sfmc_configure(with configuration: [AnyHashable : Any]) async throws -> (Bool, String, Error)

    Parameters

    configuration

    NSDictionary created by the MarketingCloudSDKConfigBuilder class

    error

    NSError object describing the error.

    completionHandler

    Called when the asynchronous portion has completed. Do not proceed if NO is returned and error will contain an error object describing the error. If completionHandler is nil, the configuration is synchronously performed and will block the calling thread.

    Return Value

    Returns YES if the configuration is successful or NO if failed. Do not proceed if NO is returned and error will contain an error object describing the error. The configuration is synchronously performed and will block the calling thread.

  • this method properly closes down the MarketingCloudSDK. It should be used in any cases where references to the MarketingCloudSDK need to be released.

    Declaration

    Objective-C

    - (void)sfmc_tearDown;

    Swift

    func sfmc_tearDown()
  • Accepts and sets the Contact Key for the device’s user. Formerly know in the SDK as “subscriberKey”.

    Cannot be nil or blank.

    Will trim leading and trailing whitespace.

    Declaration

    Objective-C

    - (BOOL)sfmc_setContactKey:(NSString *_Nonnull)contactKey;

    Swift

    func sfmc_setContactKey(_ contactKey: String) -> Bool

    Parameters

    contactKey

    The contact key to attribute to the user.

    Return Value

    YES if set successfully.

  • Returns the contact key for the active user, in case you need it.

    Declaration

    Objective-C

    - (NSString *_Nullable)sfmc_contactKey;

    Swift

    func sfmc_contactKey() -> String?

    Return Value

    contactKey The code-set contact key.

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

    Will trim leading and trailing whitespace.

    Cannot be nil or blank.

    Declaration

    Objective-C

    - (BOOL)sfmc_addTag:(NSString *_Nonnull)tag;

    Swift

    func sfmc_addTag(_ tag: String) -> Bool

    Parameters

    tag

    A string to add to the list of tags.

    Return Value

    YES if added successfully.

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

    Declaration

    Objective-C

    - (BOOL)sfmc_removeTag:(NSString *_Nonnull)tag;

    Swift

    func sfmc_removeTag(_ tag: String) -> Bool

    Parameters

    tag

    A string to remove from the list of tags.

    Return Value

    tag Echoes the tag back on successful removal, or nil if something failed.

  • 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

    Objective-C

    - (NSSet *_Nullable)sfmc_addTags:(NSArray *_Nonnull)tags;

    Swift

    func sfmc_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 array of Tags (NSString) from the list of tags.

    Declaration

    Objective-C

    - (NSSet *_Nullable)sfmc_removeTags:(NSArray *_Nonnull)tags;

    Swift

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

    Parameters

    tags

    An array of tags to removed from the list.

    Return Value

    Set of tags removed upon success, as strings, or nil if something failed.

  • Returns the list of tags for this device.

    Declaration

    Objective-C

    - (NSSet *_Nullable)sfmc_tags;

    Swift

    func sfmc_tags() -> Set<AnyHashable>?

    Return Value

    All tags associated, as strings.

  • Set an attribute to the data set sent to Salesforce.

    The Attribute Name cannot be nil or blank, or one of the reserved words.

    Will trim leading and trailing whitespace from the name and value.

    The attribute must be defined within the SFMC Contact model prior to setting a value. If the attribute does not exist within the SFMC Contact model, then this attribute will be accepted by the SDK, but will be ignored within the SFMC.

    If you previously set a value for the named attribute, then the value will be updated with the new value and sent to the SFMC.

    If you send in a blank value, then the value will be sent to the SFMC to remove that value from the Contact record.

    All attribute values set with this method persist through the installation of the app on your customer device.

    Note that attribute mapping is case sensitive, and spaces should be avoided when setting up new attributes in the SFMC Contact model.

    Declaration

    Objective-C

    - (BOOL)sfmc_setAttributeNamed:(NSString *_Nonnull)name
                             value:(NSString *_Nonnull)value;

    Swift

    func sfmc_setAttributeNamed(_ name: String, value: String) -> Bool

    Parameters

    name

    The name of the attribute you wish to send. This will be the key of the pair.

    value

    The value to set for the data pair.

    Return Value

    YES if set successfully.

  • Removes the named attribute from the data set to send to Salesforce. The value is not changed on the SFMC.

    Declaration

    Objective-C

    - (BOOL)sfmc_clearAttributeNamed:(NSString *_Nonnull)name;

    Swift

    func sfmc_clearAttributeNamed(_ name: String) -> Bool

    Parameters

    name

    The name of the attribute you wish to remove.

    Return Value

    Returns the value that was set. It will no longer be sent back to Salesforce.

  • Returns a read-only copy of the Attributes dictionary as it is right now.

    Declaration

    Objective-C

    - (NSDictionary *_Nullable)sfmc_attributes;

    Swift

    func sfmc_attributes() -> [AnyHashable : Any]?

    Return Value

    All attributes currently set.

  • Set multiple attributes (key/value dictionaries) to Salesforce. See comments in -sfmc_setAttributeNamed.

    Declaration

    Objective-C

    - (NSDictionary *_Nullable)sfmc_setAttributes:(NSArray *_Nonnull)attributes;

    Swift

    func sfmc_setAttributes(_ attributes: [Any]) -> [AnyHashable : Any]?

    Parameters

    attributes

    An array of dictionaries of key (attribute name) and value (attribute value).

    Return Value

    A set of all attributes set.

  • Remove multiple attributes from Salesforce. See comments in -sfmc_setAttributeNamed.

    Declaration

    Objective-C

    - (NSDictionary *_Nullable)sfmc_clearAttributesNamed:
        (NSArray *_Nonnull)attributeNames;

    Swift

    func sfmc_clearAttributesNamed(_ attributeNames: [Any]) -> [AnyHashable : Any]?

    Parameters

    attributeNames

    An array of attribute names.

    Return Value

    A set of all attributes removed.

  • 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

    Objective-C

    - (void)sfmc_setDeviceToken:(NSData *_Nonnull)deviceToken;

    Swift

    func sfmc_setDeviceToken(_ deviceToken: Data)

    Parameters

    deviceToken

    Token as received from Apple.

  • Returns the device token as a NSString.

    Declaration

    Objective-C

    - (NSString *_Nullable)sfmc_deviceToken;

    Swift

    func sfmc_deviceToken() -> String?

    Return Value

    NSData A stringified version of the Apple deviceToken.

  • Returns the Salesforce application ID.

    Declaration

    Objective-C

    - (NSString *_Nullable)sfmc_appID;

    Swift

    func sfmc_appID() -> String?

    Return Value

    NSString Salesforce application ID.

  • Returns the Salesforce application accessToken.

    Declaration

    Objective-C

    - (NSString *_Nullable)sfmc_accessToken;

    Swift

    func sfmc_accessToken() -> String?

    Return Value

    NSString Salesforce application accessToken.

  • Returns the unique device identifier that Salesforce will use to identify the device.

    Declaration

    Objective-C

    - (NSString *_Nullable)sfmc_deviceIdentifier;

    Swift

    func sfmc_deviceIdentifier() -> String?

    Return Value

    NSString The device identifier (a UUID) as a NSString.

  • Informs the SDK of the current notification.

    Declaration

    Objective-C

    - (void)sfmc_setNotificationRequest:(nonnull UNNotificationRequest *)request;

    Swift

    func sfmc_setNotificationRequest(_ request: UNNotificationRequest)

    Parameters

    request

    The UNNotificationRequest that generated a notification.

  • Returns the last notification delivered to the SDK.

    Declaration

    Objective-C

    - (nonnull UNNotificationRequest *)sfmc_notificationRequest;

    Swift

    func sfmc_notificationRequest() -> UNNotificationRequest

    Return Value

    UNNotificationRequest * The last UNNotificationRequest that generated a notification.

  • Informs the SDK of the current notification.

    Declaration

    Objective-C

    - (void)sfmc_setNotificationUserInfo:(nonnull NSDictionary *)userInfo;

    Swift

    func sfmc_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.

    Declaration

    Objective-C

    - (nonnull NSDictionary *)sfmc_notificationUserInfo;

    Swift

    func sfmc_notificationUserInfo() -> [AnyHashable : Any]

    Return Value

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

  • 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. Allows setting the state of pushEnabled to YES/NO. If set to NO, the application will not receive any push notifications. When this value is NO, it takes precedence over the user notifications settings (i.e., setting this to NO will always disable push.) If the user has notifications settings disabled that will override this setting and push will be disabled.

    Declaration

    Objective-C

    - (void)sfmc_setPushEnabled:(BOOL)pushEnabled;

    Swift

    func sfmc_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

    Objective-C

    - (BOOL)sfmc_pushEnabled;

    Swift

    func sfmc_pushEnabled() -> Bool

    Return Value

    returns a BOOL value of the current pushEnabled state.

  • Outputs a formatted, easily readable block of text describing the current status of the SDK.

    Declaration

    Objective-C

    - (nullable NSString *)sfmc_getSDKState;

    Swift

    func sfmc_getSDKState() -> String?

    Return Value

    JSON string with values of the current state of the SDK.

  • Enable/Disable extra debug logging from the SDK.

    Declaration

    Objective-C

    - (void)sfmc_setDebugLoggingEnabled:(BOOL)enabled;

    Swift

    func sfmc_setDebugLoggingEnabled(_ enabled: Bool)

    Parameters

    enabled

    BOOL for enabling or disabling extra SDK logging.

  • The current state of the debug logging flag in the SDK.

    Declaration

    Objective-C

    - (BOOL)sfmc_getDebugLoggingEnabled;

    Swift

    func sfmc_getDebugLoggingEnabled() -> Bool

    Return Value

    returns a BOOL value of the current debug logging state.

  • Ask MarketingCloudSDK to update its data. MarketingCloudSDK will throttle attempts based on the time since the last time this was called.

    Declaration

    Objective-C

    - (BOOL)sfmc_refreshWithFetchCompletionHandler:
        (void (^_Nullable)(UIBackgroundFetchResult))completionHandler;

    Swift

    func sfmc_refresh(fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)? = nil) -> 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.

    Return Value

    YES if MarketingCloudSDK did make an attempt at updating data.

  • Add a signedString security token for registration security

    Declaration

    Objective-C

    - (BOOL)sfmc_setSignedString:(NSString *_Nullable)signedString;

    Swift

    func sfmc_setSignedString(_ signedString: String?) -> Bool

    Parameters

    signedString

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

    Return Value

    YES if signedString was set successfully

  • 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

    Declaration

    Objective-C

    - (void)sfmc_setRegistrationCallback:
        (nonnull void (^)(NSDictionary *_Nonnull))registrationCallback;

    Swift

    func sfmc_setRegistrationCallback(_ registrationCallback: @escaping ([AnyHashable : Any]) -> Void)

    Parameters

    registrationCallback

    closure to be provided when registration event occurs

  • Declaration

    Objective-C

    - (void)sfmc_unsetRegistrationCallback;

    Swift

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

    Declaration

    Objective-C

    - (NSString *_Nullable)sfmc_signedString;

    Swift

    func sfmc_signedString() -> String?

    Return Value

    a NSString of last stored signedString security token

  • BOOL indicating whether the SDK is ready to be used.

    Declaration

    Objective-C

    - (BOOL)sfmc_isReady;

    Swift

    func sfmc_isReady() -> Bool

    Return Value

    returns YES if the SDK is initialized and ready to be used.

  • BOOL indicating the SDK is in the process of being initialized.

    Declaration

    Objective-C

    - (BOOL)sfmc_isInitializing;

    Swift

    func sfmc_isInitializing() -> Bool

    Return Value

    returns YES if the SDK is in the process of being initialized.

  • BOOL indicating the Data merge policy flag is reset to re-trigger the merge

    Declaration

    Objective-C

    - (BOOL)sfmc_resetDataPolicy;

    Swift

    func sfmc_resetDataPolicy() -> Bool

    Return Value

    returns YES if the Data merge policy is reset

Events

  • Method to set a delegate class (adhering to the MarketingCloudSDKEventDelegate protocol) to implment methods for In-App Message lifecycle events.

    Declaration

    Objective-C

    - (void)sfmc_setEventDelegate:
        (id<MarketingCloudSDKEventDelegate> _Nullable)delegate;

    Swift

    func sfmc_setEventDelegate(_ delegate: MarketingCloudSDKEventDelegate?)

    Parameters

    delegate

    the class implementing the MarketingCloudSDKEventDelegate.

  • Method to set a delegate class (adhering to the SFMCSdkInAppMessageEventDelegate protocol) to implment methods for In-App Message lifecycle events.

    Declaration

    Objective-C

    - (void)sfmc_setInAppEventDelegate:(id _Nullable)delegate;

    Swift

    func sfmc_set(inAppEventDelegate delegate: Any?)

    Parameters

    delegate

    the class implementing the SFMCSdkInAppMessageEventDelegate..

  • Extract a message identifier for an In-App Message dictionary (provided in the MarketingCloudSDKEventDelegate methods).

    Declaration

    Objective-C

    - (NSString *_Nullable)sfmc_messageIdForMessage:(NSDictionary *_Nonnull)message;

    Swift

    func sfmc_messageId(forMessage message: [AnyHashable : Any]) -> String?

    Parameters

    message

    NSDictionary representing an In-App Message

    Return Value

    string value of the message identifier

  • When called, instructs the SDK to attempt to display the In-App Message. This will cause the MarketingCloudSDKEventDelegate methods to be called, if implemented.

    Declaration

    Objective-C

    - (void)sfmc_showInAppMessage:(NSString *_Nonnull)messageId;

    Swift

    func sfmc_show(inAppMessage messageId: String)

    Parameters

    messageId

    identifier of In-App Message

  • When called, sets the font for In-App Message display.

    Declaration

    Objective-C

    - (BOOL)sfmc_setInAppMessageFontName:(NSString *_Nullable)fontName;

    Swift

    func sfmc_set(inAppMessageFontName fontName: String?) -> Bool

    Parameters

    fontName

    name of font installed on device or built into application. Note: this may be different than the font family name. If nil, the SDK default (system font) will be used.

    Return Value

    value of YES indicating that the font name is valid and can be used, NO if the font name is not valid. If nil is passed as fontName, YES will be returned.

  • Method to track events, which could result in actions such as an In-App Message displaying.

    Declaration

    Objective-C

    - (void)sfmc_track:(nullable id)events;

    Swift

    func sfmc_track(_ events: Any?)

    Parameters

    events

    event or an array of events to trigger.

InboxMessages

  • Get all active Inbox messages already downloaded from the MarketingCloud

    Declaration

    Objective-C

    - (NSArray *_Nullable)sfmc_getAllMessages;

    Swift

    func sfmc_getAllMessages() -> [Any]?

    Return Value

    array of NSDictionaries representing Inbox messages

  • Get unread active Inbox messages (already downloaded from the MarketingCloud)

    Declaration

    Objective-C

    - (NSArray *_Nullable)sfmc_getUnreadMessages;

    Swift

    func sfmc_getUnreadMessages() -> [Any]?

    Return Value

    array of NSDictionaries representing Inbox messages

  • Get active Inbox messages marked as read (already downloaded from the MarketingCloud)

    Declaration

    Objective-C

    - (NSArray *_Nullable)sfmc_getReadMessages;

    Swift

    func sfmc_getReadMessages() -> [Any]?

    Return Value

    array of NSDictionaries representing Inbox messages

  • Get active Inbox messages marked as deleted (already downloaded from the MarketingCloud)

    Declaration

    Objective-C

    - (NSArray *_Nullable)sfmc_getDeletedMessages;

    Swift

    func sfmc_getDeletedMessages() -> [Any]?

    Return Value

    array of NSDictionaries representing Inbox messages

  • Get count of all active Inbox messages already downloaded from the MarketingCloud.

    Useful for inbox count badges or other interface elements, without having to fetch messages directly.

    Declaration

    Objective-C

    - (NSUInteger)sfmc_getAllMessagesCount;

    Swift

    func sfmc_getAllMessagesCount() -> UInt

    Return Value

    number of messages

  • Get count of unread active Inbox messages (already downloaded from the MarketingCloud)

    Useful for inbox count badges or other interface elements, without having to fetch messages directly.

    Declaration

    Objective-C

    - (NSUInteger)sfmc_getUnreadMessagesCount;

    Swift

    func sfmc_getUnreadMessagesCount() -> UInt

    Return Value

    number of messages

  • Get count of active Inbox messages marked as read (already downloaded from the MarketingCloud)

    Useful for inbox count badges or other interface elements, without having to fetch messages directly.

    Declaration

    Objective-C

    - (NSUInteger)sfmc_getReadMessagesCount;

    Swift

    func sfmc_getReadMessagesCount() -> UInt

    Return Value

    number of messages

  • Get count of active Inbox messages marked as deleted (already downloaded from the MarketingCloud)

    Useful for inbox count badges or other interface elements, without having to fetch messages directly.

    Declaration

    Objective-C

    - (NSUInteger)sfmc_getDeletedMessagesCount;

    Swift

    func sfmc_getDeletedMessagesCount() -> UInt

    Return Value

    number of messages

  • Mark a Inbox message as read.

    Note: this information is persisted locally and would be reset if the SDK’s data is reset (via app delete and reinstall, for instance).

    Declaration

    Objective-C

    - (BOOL)sfmc_markMessageRead:(NSDictionary *_Nonnull)messageDictionary;

    Swift

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

    Parameters

    messageDictionary

    a dictionary representing an Inbox message

    Return Value

    a value indicatating success in setting the message to read

  • Mark an Inbox message as deleted.

    Note: this information is persisted locally and would be reset if the SDK’s data is reset (via app delete and reinstall, for instance).

    Declaration

    Objective-C

    - (BOOL)sfmc_markMessageDeleted:(NSDictionary *_Nonnull)messageDictionary;

    Swift

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

    Parameters

    messageDictionary

    a dictionary representing an Inbox message

    Return Value

    a value indicatating success in setting the message to deleted

  • Mark a Inbox message as read using messageId.

    Note: this information is persisted locally and would be reset if the SDK’s data is reset (via app delete and reinstall, for instance).

    Declaration

    Objective-C

    - (BOOL)sfmc_markMessageWithIdRead:(NSString *_Nonnull)messageId;

    Swift

    func sfmc_markMessage(withIdRead messageId: String) -> Bool

    Parameters

    messageId

    a string representing an Inbox message identifier

    Return Value

    a value indicatating success in setting the message to read

  • Mark an Inbox message as deleted using messageId.

    Note: this information is persisted locally and would be reset if the SDK’s data is reset (via app delete and reinstall, for instance).

    Declaration

    Objective-C

    - (BOOL)sfmc_markMessageWithIdDeleted:(NSString *_Nonnull)messageId;

    Swift

    func sfmc_markMessage(withIdDeleted messageId: String) -> Bool

    Parameters

    messageId

    a string representing an Inbox message identifier

    Return Value

    a value indicatating success in setting the message to deleted

  • Mark all Inbox messages as read.

    Note: this information is persisted locally and would be reset if the SDK’s data is reset (via app delete and reinstall, for instance).

    Declaration

    Objective-C

    - (BOOL)sfmc_markAllMessagesRead;

    Swift

    func sfmc_markAllMessagesRead() -> Bool

    Return Value

    a value indicatating success in setting the messages to read

  • Mark all Inbox messages as deleted.

    Note: this information is persisted locally and would be reset if the SDK’s data is reset (via app delete and reinstall, for instance).

    Declaration

    Objective-C

    - (BOOL)sfmc_markAllMessagesDeleted;

    Swift

    func sfmc_markAllMessagesDeleted() -> Bool

    Return Value

    a value indicatating success in setting the messages to deleted

  • Reload and refresh Inbox messages from the MarketingCloud server.

    Note: The underlying request to the server will be throttled such that it will execute at most every 60 seconds. If the method has been called less than 60s after the preceeding method call, NO will be returned and the request will not be made. If NO is returned, it is suggested that any UI used to reflect the refresh operation is updated (pull to refresh indicators, loading spinners, etc.).

    This method will cause notifications to be posted to NSNotificationCenter:

    • SFMCInboxMessagesRefreshCompleteNotification: posted when the refresh process has completed
    • SFMCInboxMessagesNewInboxMessagesNotification: posted if there are new Inbox messages

    Declaration

    Objective-C

    - (BOOL)sfmc_refreshMessages;

    Swift

    func sfmc_refreshMessages() -> Bool

    Return Value

    A BOOL value indicating that refreshing has been started.

  • Create an instance of a basic UITableView data source to handle all loading for a simple view controller showing Inbox messages.

    Declaration

    Objective-C

    - (MarketingCloudSDKInboxMessagesDataSource *_Nullable)
        sfmc_inboxMessagesTableViewDataSourceForTableView:
            (UITableView *_Nonnull)tableView;

    Swift

    func sfmc_inboxMessagesTableViewDataSource(for tableView: UITableView) -> MarketingCloudSDKInboxMessagesDataSource?

    Parameters

    tableView

    The UITableView used in the view controller. The data source will “own” population of the data and display of simple cells.

    Return Value

    An instance of MarketingCloudSDKInboxMessagesDataSource, a class which implements a simple set of methods from the UITableViewDataSource protocol.

  • Create an instance of a basic UITableView delegate to handle cell selection for a simple view controller showing Inbox messages.

    Declaration

    Objective-C

    - (MarketingCloudSDKInboxMessagesDelegate *_Nullable)
        sfmc_inboxMessagesTableViewDelegateForTableView:
            (UITableView *_Nonnull)tableView
                                             dataSource:
                                                 (MarketingCloudSDKInboxMessagesDataSource
                                                      *_Nonnull)dataSource;

    Swift

    func sfmc_inboxMessagesTableViewDelegate(for tableView: UITableView, dataSource: MarketingCloudSDKInboxMessagesDataSource) -> MarketingCloudSDKInboxMessagesDelegate?

    Parameters

    tableView

    The UITableView used in the view controller. The delegate will “own” selection of the cells.

    dataSource

    An instance of MarketingCloudSDKInboxMessagesDataSource, a class which implements a simple set of methods from the UITableViewDataSource protocol.

    Return Value

    An instance of MarketingCloudSDKInboxMessagesDelegate, a class which implements a simple set of methods from the UITableViewDelegate protocol.

Intelligence

  • Set the identifier to associate with Predictive Intelligence data sent to Salesforce Marketing Cloud

    The clear the value, pass a nil value.

    Will trim leading and trailing whitespace from the string.

    An identifier will persist until it is cleared or changed and will used to associate with all analytic events generated while set.

    Declaration

    Objective-C

    - (BOOL)sfmc_setPiIdentifier:(NSString *_Nullable)identifier;

    Swift

    func sfmc_setPiIdentifier(_ identifier: String?) -> Bool

    Parameters

    identifier

    The string you want to associate analytics with.

    Return Value

    YES if set successfully.

  • Returns a read-only copy of the Analytics identity set

    Declaration

    Objective-C

    - (NSString *_Nullable)sfmc_piIdentifier;

    Swift

    func sfmc_piIdentifier() -> String?

    Return Value

    All attributes currently set.

  • When an Inbox message is opened (for instance, you implement an inbox and present the CloudPage URL in your webview) this method should be called with the Inbox message so that the MarketingCloudSDK can track the proper analytics and state of the message.

    Declaration

    Objective-C

    - (void)sfmc_trackMessageOpened:(NSDictionary *_Nonnull)inboxMessage;

    Swift

    func sfmc_trackMessageOpened(_ inboxMessage: [AnyHashable : Any])

    Parameters

    inboxMessage

    a non-nil NSDictionary object representing an Inbox message

  • Track page views within your application.

    Declaration

    Objective-C

    - (void)sfmc_trackPageViewWithURL:(NSString *_Nonnull)url
                                title:(NSString *_Nullable)title
                                 item:(NSString *_Nullable)item
                               search:(NSString *_Nullable)search;

    Swift

    func sfmc_trackPageView(withURL url: String, title: String?, item: String?, search: String?)

    Parameters

    url

    a non-nil NSString to identify the location within your app traversed by your customers. For example: com.yourpackage.viewcontrollername

    title

    a NSString (nil if n/a) to identify the title of the location within your app traversed by your customers. For example: Screen Name

    item

    a NSString (nil if n/a) to identify an item viewed by your customer. For example: UPC-1234

    search

    a NSString (nil if n/a) to identify search terms used by your customer. For example: blue jeans.

  • Track cart contents within your application.

    Declaration

    Objective-C

    - (void)sfmc_trackCartContents:(NSDictionary *_Nonnull)cartDictionary;

    Swift

    func sfmc_trackCartContents(_ cartDictionary: [AnyHashable : Any])

    Parameters

    cartDictionary

    a non-nil NSDictionanry object containing a cartID and an array of cart item dictionaries

  • Track cart conversion within your application.

    Declaration

    Objective-C

    - (void)sfmc_trackCartConversion:(NSDictionary *_Nonnull)orderDictionary;

    Swift

    func sfmc_trackCartConversion(_ orderDictionary: [AnyHashable : Any])

    Parameters

    orderDictionary

    a non-nil NSDictionanry object representing an order; created from a cart and cart items and “converted” into a sale of some sort

  • Initialize a Cart Item dictionary for use in analytics.

    Declaration

    Objective-C

    - (NSDictionary *_Nullable)
        sfmc_cartItemDictionaryWithPrice:(NSNumber *_Nonnull)price
                                quantity:(NSNumber *_Nonnull)quantity
                                    item:(NSString *_Nonnull)item
                                uniqueId:(NSString *_Nullable)uniqueId;

    Swift

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

    Parameters

    price

    The price amount (USD) of this item (non-nil value; 0 permissable)

    quantity

    The count of items in the cart for this particular product (non-nil value; greater than zero)

    item

    The unique product code from the e-commerce system representing this cart item (non-nil string value)

    uniqueId

    The unique product id. from the e-commerce system representing this cart item (string value; nil permissable)

    Return Value

    instancetype a NSDictionary representing a cart item.

  • Initialize a Cart dictionary for use in analytics.

    Declaration

    Objective-C

    - (NSDictionary *_Nullable)sfmc_cartDictionaryWithCartItemDictionaryArray:
        (NSArray *_Nonnull)cartItemDictionaryArray;

    Swift

    func sfmc_cartDictionary(withCartItemDictionaryArray cartItemDictionaryArray: [Any]) -> [AnyHashable : Any]?

    Parameters

    cartItemDictionaryArray

    An array of cart item dictionary objects (non-nil array). An empty array indicates an empty cart, and will be used to indicate a cleared cart to the analytics system.

    Return Value

    instancetype a MarketingCloudSDKCart.

  • Initialize an Order dictionary for use in analytics.

    Declaration

    Objective-C

    - (NSDictionary *_Nullable)
        sfmc_orderDictionaryWithOrderNumber:(NSString *_Nonnull)orderNumber
                                   shipping:(NSNumber *_Nonnull)shipping
                                   discount:(NSNumber *_Nonnull)discount
                                       cart:(NSDictionary *_Nonnull)cartDictionary;

    Swift

    func sfmc_orderDictionary(withOrderNumber orderNumber: String, shipping: NSNumber, discount: NSNumber, cart cartDictionary: [AnyHashable : Any]) -> [AnyHashable : Any]?

    Parameters

    orderNumber

    The order number of from the e-commerce system (non-nil string)

    shipping

    The shipping amount (USD) of this order (non-nil value; 0 permissable)

    discount

    The discount amount (USD) of this order (non-nil value; 0 permissable)

    cartDictionary

    The order’s shopping cart object (non-nil object)

    Return Value

    instancetype a NSDictionary representing an order.

Location

  • Method to set a delegate implementing the MarketingCloudSDKLocationDelegate.

    Declaration

    Objective-C

    - (void)sfmc_setLocationDelegate:
        (id<MarketingCloudSDKLocationDelegate> _Nullable)delegate;

    Swift

    func sfmc_setLocationDelegate(_ delegate: MarketingCloudSDKLocationDelegate?)

    Parameters

    delegate

    value A class adhering to the MarketingCloudSDKLocationDelegate and implementing the required method.

  • Method to set a delegate implementing the MarketingCloudSDKLocationDelegate.

    Declaration

    Objective-C

    - (void)sfmc_setSFMCSdkLocationDelegate:(id _Nullable)delegate;

    Swift

    func sfmc_setSFMCSdkLocationDelegate(_ delegate: Any?)

    Parameters

    delegate

    value A class adhering to the MarketingCloudSDKLocationDelegate and implementing the required method.

  • Method to convert a region dictionary returned from sfmc_shouldShowLocationMessage into a CLRegion

    Declaration

    Objective-C

    - (CLRegion *_Nullable)sfmc_regionFromDictionary:
        (NSDictionary *_Nonnull)dictionary;

    Swift

    func sfmc_region(from dictionary: [AnyHashable : Any]) -> CLRegion?

    Parameters

    dictionary

    value representing a region object from the sfmc_shouldShowLocationMessage method

  • Determines the state of Location Services based on developer setting and OS-level permission. This is the preferred method for checking for location state.

    Declaration

    Objective-C

    - (BOOL)sfmc_locationEnabled;

    Swift

    func sfmc_locationEnabled() -> Bool

    Return Value

    A boolean value reflecting if location services are enabled (i.e. authorized) or not.

  • Use this method to initiate Location Services through the MobilePush SDK.

    Declaration

    Objective-C

    - (void)sfmc_startWatchingLocation;

    Swift

    func sfmc_startWatchingLocation()
  • Use this method to disable Location Services through the MobilePush SDK.

    Declaration

    Objective-C

    - (void)sfmc_stopWatchingLocation;

    Swift

    func sfmc_stopWatchingLocation()
  • Use this method to determine if the SDK is actively monitoring location.

    Declaration

    Objective-C

    - (BOOL)sfmc_watchingLocation;

    Swift

    func sfmc_watchingLocation() -> Bool

    Return Value

    A boolean value reflecting if the SDK has called startWatchingLocation.

  • A dictionary version of the last known Location. The dictionary will contain two keys, latitude and longitude, which are NSNumber wrappers around doubles. Use doubleValue to retrieve.

    Declaration

    Objective-C

    - (NSDictionary<NSString *, NSString *> *_Nullable)sfmc_lastKnownLocation;

    Swift

    func sfmc_lastKnownLocation() -> [String : String]?

URLHandling

  • Method to set a delegate implementing the MarketingCloudSDKURLHandlingDelegate.

    Declaration

    Objective-C

    - (void)sfmc_setURLHandlingDelegate:
        (id<MarketingCloudSDKURLHandlingDelegate> _Nullable)delegate;

    Swift

    func sfmc_setURLHandlingDelegate(_ delegate: MarketingCloudSDKURLHandlingDelegate?)

    Parameters

    delegate

    value A class adhering to the MarketingCloudSDKURLHandlingDelegate and implementing the required method.

  • Method to set a delegate implementing the MarketingCloudSDKURLHandlingDelegate.

    Declaration

    Objective-C

    - (void)sfmc_setSFMCSdkURLHandlingDelegate:(id _Nullable)delegate;

    Swift

    func sfmc_setSFMCSdkURLHandlingDelegate(_ delegate: Any?)

    Parameters

    delegate

    value A class adhering to the MarketingCloudSDKURLHandlingDelegate and implementing the required method.