Skip to content

Shared Hardware Id

Mihály Hunyady edited this page May 9, 2022 · 5 revisions

Shared Hardware Id

What is shared hardware id?

From 2.7.0 Emarsys SDK provides a solution to share the hardware identifier between your applications, that has Emarsys SDK integrated.

Required steps at integration

For this to work, some additional steps are required.

1. Add Keychain Sharing capability to the desired target in XCode

Note

Please pay extra attention to having your application's private access group (probably your bundleId) as the first entry in the accessGroups list, as Apple will default to the first item in the list whenever no accessGroup is used while using the keychain. This is very important because misconfiguration of this part can cause data loss in the EmarsysSDK.

To learn more about Keychain sharing read the official Apple article about the topic

Shared Keychain Capability Screenshot

2. Call setSharedKeychainAccessGroup on EMSConfig builder at setup

setSharedKeychainAccessGroup should be called with the chosen shared keyhchain access group, which was previously set up in XCode, prefixed by your teamId (you can look it up on apple developer site under Certificates, Identifiers & Profiles -> Identifiers -> App Id prefix eg: "XXXXXXXXX.com.emarsys.Shared")

Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    EMSConfig *config = [EMSConfig makeWithBuilder:^(EMSConfigBuilder *builder) {
        [builder setMobileEngageApplicationCode:<applicationCode: NSString>];
        [builder setMerchantId:<merchantId: NSString>];
        [builder setSharedKeychainAccessGroup:<sharedKeychainAccessGroup: NSString>];
    }];
    [Emarsys setupWithConfig:config];

    return YES;
}
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let config = EMSConfig.make { builder in
        builder.setMobileEngageApplicationCode(<applicationCode: String>)
        builder.setMerchantId(<merchantId: String>)
        builder.sharedKeychainAccessGroup(<sharedKeychainAccessGroup: String>)
    }
    Emarsys.setup(with: config)

    return true
}