-
Notifications
You must be signed in to change notification settings - Fork 19
Shared Hardware Id
Note
The development of this feature is in progress, please do not use it in production releases!
Shared Hardware Id is enabled from SDK version 2.12
From 2.12.0 Emarsys SDK provides a solution to share the hardware identifier between your applications, that has Emarsys SDK integrated.
The SDK uses a ContentProvider to share encrypted hardware id
between the applications in a secure way. For this to work a shared secret is needed in every application what needs this shared hardware id
.
- If no secret is added to the Emarsys Config:
- and there is a stored
hardware id
already, the SDK works as before and uses the storedhardware id
and doesn't provide it to other applications - but there is no
hardware id
stored, the SDK generates a new one and stores it
- and there is a stored
- If there is a secret added to the Emarsys Config:
- and there is a stored
hardware id
, the SDK uses that and makes it available through a ContentProvider and provides it in an encrypted form, to authorised applications - the SDK asks for a
hardware id
from the other applications configured insharedPackageNames
, and uses the one it found, or - if no
hardware id
found, the SDK generates one and makes it available through a ContentProvider and provides it in an encrypted form, to authorised applications
- and there is a stored
With the behaviour above the SDK works fine and compatible with every previous versions.
The existing hardware id
of an app will not be changed, if the secret is added later.
The following modifications must be done in all of your applications.
Call EmarsysConfig.Builder.sharedPackageNames(sharedPackageNames: List)
before the setup, where the sharedPackageNames
is the list of the package names of your other applications.
Set your secret in the Config of your applications with the EmarsysConfig.Builder.sharedSecret(sharedSecret: String)
method. This secret can be any String, and it's mandatory to be the same in all your applications.
In your manifest file add the provider tag inside your application tag, and the queries tag inside the manifest tag. The content of these are listed below.
<provider
android:name="com.emarsys.provider.SharedHardwareIdentificationContentProvider"
android:authorities="${applicationId}"
android:enabled="true"
android:exported="true"
android:grantUriPermissions="true" />
In the <package android:name="APPLICATION_PACKAGE">
the APPLICATION_PACKAGE is your other application's package name.
<queries>
<package android:name="APPLICATION_PACKAGE" />
</queries>
public class SampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
EmarsysConfig config = new EmarsysConfig.Builder()
.application(this)
.mobileEngageApplicationCode(<applicationCode:String?>)
.contactFieldId(<contactFieldId: Integer>)
.predictMerchantId(<predictMerchantId:String?>)
.inAppEventHandler(getInAppEventHandler())
.notificationEventHandler(getNotificationEventHandler())
.sharedPackageNames(<sharedPackageNames: List<String>>)
.sharedSecret(<sharedSecret: String>)
.build();
Emarsys.setup(config);
}
}
class SampleApplication: Application() {
override fun onCreate() {
super.onCreate()
val config = EmarsysConfig.Builder()
.application(this)
.mobileEngageApplicationCode(<applicationCode: String?>)
.contactFieldId(<contactFieldId: Integer>)
.predictMerchantId(<predictMerchantId:String?>)
.inAppEventHandler(getInAppEventHandler())
.notificationEventHandler(getNotificationEventHandler())
.sharedPackageNames(<sharedPackageNames: List<String>>)
.sharedSecret(<sharedSecret: String>)
.build()
Emarsys.setup(config)
}
}