DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
Class
This class is a Swift Interface for SFMarketingCloudSdk
1@objc(SFMarketingCloudSdk)
2public final class MarketingCloudSdk : NSObject, SFMCModule, Publisher
3
4@objc
5public static func requestSdk(_ callback: @escaping (_ marketingCloudSdk: MarketingCloudSdkInterface?) -> Void)
6
7@objc
8public static func metadata() -> [String : Any]
9
10public func refresh(fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)?) -> Bool
11
12public func setDebugLoggingEnabled(_ enabled: Bool)
13
14@objc
15public static func getLogger() -> ModuleLogger
16
17public func contactKey() -> String?
18
19public func addTag(_ tag: String) -> Bool
20
21public func addTags(_ tags: [Any]) -> Set<AnyHashable>?
22
23public func removeTag(_ tag: String) -> Bool
24
25public func tags() -> Set<AnyHashable>?
26
27public func attributes() -> [AnyHashable : Any]?
28
29public func accessToken() -> String?
30
31public func deviceIdentifier() -> String?
32
33public func setSignedString(_ signedString: String?) -> Bool
34
35public func signedString() -> String?
36
37public func setRegistrationCallback(_ registrationCallback: @escaping (Dictionary<AnyHashable, Any>) -> Void)
38
39public func unsetRegistrationCallback()
40
41public func setAnalyticsEnabled(_ analyticsEnabled: Bool)
42
43public func isAnalyticsEnabled() -> Bool
44
45public func setPiAnalyticsEnabled(_ analyticsEnabled: Bool)
46
47public func isPiAnalyticsEnabled() -> Bool
48
49public func isLocationEnabled() -> Bool
50
51public func setLocationEnabled(_ locationEnabled: Bool)
52
53public func isInboxEnabled() -> Bool
54
55public func setInboxEnabled(_ inboxEnabled: Bool)
56
57public func getAllMessages() -> [Any]?
58
59public func getUnreadMessages() -> [Any]?
60
61public func getReadMessages() -> [Any]?
62
63public func getDeletedMessages() -> [Any]?
64
65public func getAllMessagesCount() -> UInt
66
67public func getUnreadMessagesCount() -> UInt
68
69public func getReadMessagesCount() -> UInt
70
71public func getDeletedMessagesCount() -> UInt
72
73public func markMessageRead(_ messageDictionary: [AnyHashable : Any]) -> Bool
74
75public func markMessageDeleted(_ messageDictionary: [AnyHashable : Any]) -> Bool
76
77public func markMessageWithIdRead(messageId: String) -> Bool
78
79public func markMessageWithIdDeleted(messageId: String) -> Bool
80
81public func markAllMessagesRead() -> Bool
82
83public func markAllMessagesDeleted() -> Bool
84
85public func refreshMessages() -> Bool
86
87public func setPiIdentifier(_ identifier: String?) -> Bool
88
89public func piIdentifier() -> String?
90
91public func trackMessageOpened(_ inboxMessage: [AnyHashable : Any])
92
93public func trackPageView(url: String, title: String?, item: String?, search: String?)
94
95public func trackCartContents(_ cartDictionary: [AnyHashable : Any])
96
97public func trackCartConversion(_ orderDictionary: [AnyHashable : Any])
98
99public func cartItemDictionary(price: NSNumber, quantity: NSNumber, item: String, uniqueId: String?) -> [AnyHashable : Any]?
100
101public func cartDictionary(cartItem: [Any]) -> [AnyHashable : Any]?
102
103public func orderDictionary(orderNumber: String, shipping: NSNumber, discount: NSNumber, cart: [AnyHashable : Any]) -> [AnyHashable : Any]?
104
105public func setLocationDelegate(_ delegate: LocationDelegate?)
106
107public func regionFrom(dictionary: [AnyHashable : Any]) -> CLRegion?
108
109public func locationEnabled() -> Bool
110
111public func startWatchingLocation()
112
113public func stopWatchingLocation()
114
115public func watchingLocation() -> Bool
116
117public func lastKnownLocation() -> [String : String]?Requests the MarketingCloudSdk Module when it’s operational and safe to use. The provided callback will be invoked with the MarketingCloudSdk Module when it’s ready. All MarketingCloudSdk module-related API calls should be made within this function.
1@objc
2public static func requestSdk(_ callback: @escaping (_ marketingCloudSdk: MarketingCloudSdkInterface?) -> Void)This method is to get the SDK metadata
1@objc
2public static func metadata() -> [String : Any]Ask MarketingCloudSDK to update its data. MarketingCloudSDK will throttle attempts based on the time since the last time this was called.
1public func refresh(fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)?) -> BoolEnable/Disable extra debug logging from the SDK.
1public func setDebugLoggingEnabled(_ enabled: Bool)Unified Logger initialized for ‘MarketingCloudSdk’ Module Usage Example: MarketingCloudSdk.shared.getLogger().d(category: .event, message: “Message”)
1@objc
2public static func getLogger() -> ModuleLogger1public func contactKey() -> String?Returns: Contact key String that is set in the application.
Adds the provided Tag (NSString) to the set of unique tags.
1public func addTag(_ tag: String) -> BoolReturns: 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.
1public func addTags(_ tags: [Any]) -> Set<AnyHashable>?Returns: Set of tags added, as strings, or nil if something failed.
Removes the provided Tag (NSString) from the list of tags.
1public func removeTag(_ tag: String) -> BoolReturns: YES if removed successfully.
Returns the list of tags for this device.
1public func tags() -> Set<AnyHashable>?Returns: All tags associated, as strings.
Returns a read-only copy of the Attributes dictionary as it is right now.
1public func attributes() -> [AnyHashable : Any]?Returns the Salesforce application accessToken.
1public func accessToken() -> String?Returns the unique device identifier that Salesforce will use to identify the device.
1public func deviceIdentifier() -> String?Add a signedString security token for registration security
1public func setSignedString(_ signedString: String?) -> BoolReturns the value of last stored signedString security token
1public func signedString() -> String?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
1public func setRegistrationCallback(_ registrationCallback: @escaping (Dictionary<AnyHashable, Any>) -> Void)Removes the registration callback @see: https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/sdk-implementation/user-data.html
1public func unsetRegistrationCallback()Developer override to set the state of analytics enablement to YES/NO. If set to NO, the SDK will stop tracking analytics and also purges all the analytics stored locally. This value takes precedence over the config setting which is passed during the SDK initialization.
1public func setAnalyticsEnabled(_ analyticsEnabled: Bool)The current state of the Analytics enablement override
1public func isAnalyticsEnabled() -> BoolDeveloper override to set the state of PI analytics enablement to YES/NO. If set to NO, the SDK will stop tracking PI analytics and also purges all the analytics stored locally. This value takes precedence over the config setting which is passed during the SDK initialization.
1public func setPiAnalyticsEnabled(_ analyticsEnabled: Bool)The current state of the PI Analytics enablement override
1public func isPiAnalyticsEnabled() -> BoolThe current state of the Location enablement override
1public func isLocationEnabled() -> BoolDeveloper override to set the state of Location enablement to YES/NO. If set to NO, the SDK will stop monitoring location and Location services are not available for the consuming application. This value takes precedence over the config setting which is passed during the SDK initialization.
1public func setLocationEnabled(_ locationEnabled: Bool)The current state of the Inbox enablement override
1public func isInboxEnabled() -> BoolDeveloper override to set the state of Inbox enablement to YES/NO. If set to NO, Inbox feature will be disabled. This value takes precedence over the config setting which is passed during the SDK initialization.
1public func setInboxEnabled(_ inboxEnabled: Bool)Returns an array of all messages that includes read, unread , deleted messages Public properties in inbox message dictionary
1public func getAllMessages() -> [Any]?Returns: an Array of Dictionary containing all messages (read, unread and deleted)
Returns an array of unread messages Public properties in inbox message dictionary
1public func getUnreadMessages() -> [Any]?Returns an array of read messages Public properties in inbox message dictionary
1public func getReadMessages() -> [Any]?Returns an array of deleted messages Public properties in inbox message dictionary
1public func getDeletedMessages() -> [Any]?Returns all messages count
1public func getAllMessagesCount() -> UIntReturns unread messages count
1public func getUnreadMessagesCount() -> UIntReturns read messages count
1public func getReadMessagesCount() -> UIntReturns deleted messages count
1public func getDeletedMessagesCount() -> UIntMark the unread messages as read
1public func markMessageRead(_ messageDictionary: [AnyHashable : Any]) -> BoolMark the messages as deleted
1public func markMessageDeleted(_ messageDictionary: [AnyHashable : Any]) -> BoolMark the message with specific messageId as read
1public func markMessageWithIdRead(messageId: String) -> BoolMark the message with specific messageId as deleted
1public func markMessageWithIdDeleted(messageId: String) -> BoolMark all the messages with specific messageId as read
1public func markAllMessagesRead() -> BoolMark all the messages with specific messageId as deleted
1public func markAllMessagesDeleted() -> BoolFetches and refreshes messages from server Reload and refresh Inbox messages from the Marketing Cloud 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 60 seconds after the preceeding method call, NO will be returned and the request will not be made. If NO is returned, best practice is that any UI used to reflect the refresh operation is updated (pull to refresh indicators, loading spinners, etc.). DDoS Protection The SDK has several built in mechanisms to protect Marketing Cloud servers and services. For message GET routes, we allow at most one manual refresh request per minute. This prevents bad application implementations or mobile app users from calling refresh over and over when there will be no new data available. Within the SDK and it’s logging, this presents a 429 - Too Many Requests log statement. Throttling To protect the workload and ensure optimal performance, the Inbox Message routes may throttle incoming requests. This throttling is based on adaptive logic, which operates as a percentage of traffic depending on the current load. The system is designed to automatically determine when throttling is necessary or when it can be reduced. During periods of traffic throttling, some customer requests may receive a 429 - Too Many Requests response. This will log a 429 response within the SDK. The Marketing Cloud has considerable server-side logic to monitor and adjust this throttling mechanism. 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
1public func refreshMessages() -> BoolSet String identifier
1public func setPiIdentifier(_ identifier: String?) -> BoolReturns piIdentifier
1public func piIdentifier() -> String?Track the inbox messages that are opened in the app
1public func trackMessageOpened(_ inboxMessage: [AnyHashable : Any])Track the pageview visited in the page
1public func trackPageView(url: String, title: String?, item: String?, search: String?)Track contents in the cart
1public func trackCartContents(_ cartDictionary: [AnyHashable : Any])Track Conversion on the items in the cart
1public func trackCartConversion(_ orderDictionary: [AnyHashable : Any])Returns cartItem Dictionary with specific price, quantity, item and Id
1public func cartItemDictionary(price: NSNumber, quantity: NSNumber, item: String, uniqueId: String?) -> [AnyHashable : Any]?Returns cart Dictionary with cartItem
1public func cartDictionary(cartItem: [Any]) -> [AnyHashable : Any]?Returns order Dictionary with ordernumber, shipping number, discount, cart dictionary
1public func orderDictionary(orderNumber: String, shipping: NSNumber, discount: NSNumber, cart: [AnyHashable : Any]) -> [AnyHashable : Any]?Set location delegate
1public func setLocationDelegate(_ delegate: LocationDelegate?)Returns region from collection of region
1public func regionFrom(dictionary: [AnyHashable : Any]) -> CLRegion?Returns if location is enabled in the SDK
1public func locationEnabled() -> BoolEnables the co-ordinates tracking on the device
1public func startWatchingLocation()Disables the co-ordinates tracking on the device
1public func stopWatchingLocation()Returns if location watching is enabled or not
1public func watchingLocation() -> BoolReturns last known location
1public func lastKnownLocation() -> [String : String]?