Set the Contact Key to a specific value provided by your customer or some other unique identifier for the Contact like mobile number, e-mail address, customer number, etc.

NOTE: The SDK will send changes to Contact Key to the Marketing Cloud with a REST call one minute after the first change to any Marketing Cloud data. If the REST call fails (no network for example), then it will retry in one minute intervals until the app is suspended. If the send is unsuccessful before the app is suspended, the data will be sent the next time the app is opened. It will take up to 5 minutes for this value to be recorded in the Contact record once the REST call is made by the SDK.”

setContactKey() and getContactKey()

NOTE: Prior to release 4.0.0, the SDK would set a default Contact Key to a unique hash called DeviceId. Because this can cause duplicate records for companies who import contacts, the SDK stopped setting a default Contact Key.

NOTE: Contact Key may not be null or an empty string. Also, leading and/or trailing whitespace will be removed.

NOTE: By default, if your app does not set the Contact Key using setContactKey(), the Marketing Cloud will match the registration sent with a Contact Record that matches the System Token included in the registration payload. If the Marketing Cloud does not find a match, the Marketing Cloud will set a new Contact Key and will not send the value back to the SDK.