For iOS applications upgraded from SDK versions 7.x to versions up to 8.0.6, the previous v7.x tags and attributes are retained on the device but not sent to the server. If an application doesn’t reset or regenerate tags and attributes, the device sends empty tags and attributes to the system.
The following sections walk through the requirements for merging datasets successfully.
Using SPM, upgrade to the latest version of the SDK for iOS and SFMCSDK for iOS.
Swift Compilation Error
You may encounter a build failure if the Swift compiler version used to build the SDK doesn’t match the version used by your current Xcode toolchain.
The build fails with this error:
1X86_64-apple-ios-simulator.private.swiftinterface23failed to build module 'PushFeatureSDK'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.1.2...', while this compiler is 'Apple Swift version 6.2.3...'). Please select a toolchain which matches the SDK.45'PushFeatureProtocol' is unavailable: cannot find Swift declaration for this protocol.
To resolve this issue, follow these steps to reset your environment:
Clear Derived Data.
Remove the SDK dependencies from your project and then add them back again.
Clean and Run.
Merge Data (Optional)
The merging tool offers two options to merge attributes and tags: automatic merging and manual merging. In some scenarios, you can choose to defer or avoid merging the datasets. The merging tool defaults to an “opted out” state if you don’t implement either of the merging methods. In the opted out state, tags and attributes aren’t merged from the version 7.x dataset to your current application’s dataset.
Automatic Merging
The automatic merging option attempts to merge old data into the current dataset, with the current data taking precedence over data within the version 7.x dataset.
The following tables illustrate how automatic merging behaves and how data is merged.
in this tables, key:value pairs are denoted using : as the separator.
Note
Attributes
Prior Dataset
Current Dataset
Merge Result
A:B
empty
A:B
empty
A:B
A:B
A:B, C:D
A:E
A:E, C:D
A:B
A: cleared
A: cleared
Tags
Prior Dataset
Current Dataset
Merge Result
SHIRTS
empty
SHIRTS
empty
PANTS
PANTS
SHIRTS
PANTS
SHIRTS, PANTS
SHIRTS
SHIRTS, PANTS
SHIRTS, PANTS
The following code snippets show you how to configure the SDK to attempt an automatic merge.
To ensure the completion callback passed into setAutoMergePolicy is set before SDK initialization, place the following code snippets before SDK initialization.
The manual merge option enables you to receive both the prior data and the current data in a callback, providing the opportunity to choose what data ultimately ends up in the final dataset.
You can decide what attributes and tags are set in the current dataset. However, to set attributes and tags accordingly, you must retain the data until the SDK is initialized.
Access to the tags and attributes for versions 7.x and 8.x is provided before SDK initialization.
Important
Swift
10.x
1class ExampleDelegate: UIResponder, UIApplicationDelegate {23 var setTagsAndAttributes: (() ->())? = nil45 // ...6}78// ...9SFMCSdk.setManualMergePolicy(withHandler: {(v8, v9)in1011 self.setTags = {12 let tags: [String] = // e.g. v9["tags"]13 MarketingCloudSdk.requestSdk{ mc in14 mc?.addTags(tags)15}16}17}1819private func handleSDKInitializationCompletion(status: [ModuleInitStatus]){20 // ...21 if moduleStatus.initStatus == .success {22 // Handle successful initialization for each module23 switch moduleStatus.moduleName {24 case .engagement:25 self.setTags?()26 // Handle successful initialization for Marketing cloud module27}28}29 // ...30}3132// ...3334SFMCSdk.initializeSdk(configBuilder.build(), completion: completionHandler)
8.x
1class ExampleDelegate: UIResponder, UIApplicationDelegate {23 var setTagsAndAttributes: (() ->())? = nil45 // ...6}78// ...9SFMCSdk.setManualMergePolicy(withHandler: {(v7, v8)in1011 self.setTagsAndAttributes = {12 let attributes: [String:String] = // e.g. v8["attributes"] as! [String : String]13 SFMCSdk.identity.setProfileAttributes([ModuleName.push : attributes])1415 let tags: [String] = // e.g. v8["tags"]16 SFMCSdk.requestPushSdk{ mp in17 mp.addTags(tags)18}19}20}2122// ...2324let completionHandler: (OperationResult) ->() = { result in25 // ...26 if result == .success {27 // ...28 if(SFMCSdk.mp.getStatus() == .operational){29 self.setTagsAndAttributes?()30}31 // ...32}33}3435// ...3637SFMCSdk.initializeSdk(ConfigBuilder().setPush(config: configuration, onCompletion: completionHandler).build())