MarketingCloudSdk
@objc(SFMarketingCloudSdk)
public final class MarketingCloudSdk : NSObject, SFMCModule, Publisher
extension MarketingCloudSdk: Subscriber
extension MarketingCloudSdk: MarketingCloudSdkInterface
This class is a Swift Interface for SFMarketingCloudSdk
-
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.
Declaration
Swift
@objc public static func requestSdk(_ callback: @escaping (_ marketingCloudSdk: MarketingCloudSdkInterface?) -> Void)Parameters
callbackA callback that will receive the MarketingCloudSdk Module when it’s operational/ready.
-
This method is to get the SDK metadata
Declaration
Swift
@objc public 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.
Declaration
Swift
public func refresh(fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)?) -> BoolParameters
completionHandlerThe 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.
-
Enable/Disable extra debug logging from the SDK.
Declaration
Swift
public func setDebugLoggingEnabled(_ enabled: Bool)Parameters
enabledBOOL for enabling or disabling extra SDK logging.
-
Unified Logger initialized for ‘MarketingCloudSdk’ Module ### Usage Example: ### MarketingCloudSdk.shared.getLogger().d(category: .event, message: “Message”)
Declaration
Swift
@objc public static func getLogger() -> ModuleLogger
-
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) -> BoolParameters
tagA 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
tagsAn 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) -> BoolParameters
tagA 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.
-
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? -
Add a signedString security token for registration security
Declaration
Swift
public func setSignedString(_ signedString: String?) -> BoolParameters
signedStringsignedString opaque token used to verify registration. pass nil to clear signedString.
-
Returns the value of last stored signedString security token
Declaration
Swift
public 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
Declaration
Swift
public 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
Declaration
Swift
public 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.
Declaration
Swift
public func setAnalyticsEnabled(_ analyticsEnabled: Bool) -
The current state of the Analytics enablement override
Declaration
Swift
public func isAnalyticsEnabled() -> Bool -
Developer 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.
Declaration
Swift
public func setPiAnalyticsEnabled(_ analyticsEnabled: Bool) -
The current state of the PI Analytics enablement override
Declaration
Swift
public func isPiAnalyticsEnabled() -> Bool -
The current state of the Location enablement override
Declaration
Swift
public func isLocationEnabled() -> Bool -
Developer 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.
Declaration
Swift
public func setLocationEnabled(_ locationEnabled: Bool)Parameters
locationEnabledBool value to enabled/disable geofence at runtime
-
Set String identifier
Declaration
Swift
public func setPiIdentifier(_ identifier: String?) -> BoolParameters
identifierIdentifier to be set
-
Returns piIdentifier
Declaration
Swift
public func piIdentifier() -> String? -
Track the pageview visited in the page
Declaration
Swift
public func trackPageView(url: String, title: String?, item: String?, search: String?)Parameters
urlurl String
titleTitle of the pageview
itemitem String
searchsearch String
-
Track contents in the cart
Declaration
Swift
public func trackCartContents(_ cartDictionary: [AnyHashable : Any])Parameters
cartDictionaryCollection of items to be tracked
-
Track Conversion on the items in the cart
Declaration
Swift
public func trackCartConversion(_ orderDictionary: [AnyHashable : Any])Parameters
orderDictionaryCollection 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
quantitycar item Dictionary should be returned by quantity
itemitem by which the car item Dictionary should be returned
uniqueIdUnique 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
cartItemCollection 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
orderNumberOrder Dictionary returned by orderNumber
shippingOrder Dictionary returned by shipping
discountOrder Dictionary returned by discount
cartOrder Dictionary returned by cart
-
Set location delegate
Declaration
Swift
public func setLocationDelegate(_ delegate: LocationDelegate?)Parameters
delegateLocation delegate
-
Returns region from collection of region
Declaration
Swift
public func regionFrom(dictionary: [AnyHashable : Any]) -> CLRegion?Parameters
dictionaryCollection 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]?
MarketingCloudSdk Class Reference