Contacts
Identify contacts, reset contacts, and get named user IDs.
A contact is any user in your project. Contacts are identified as either an anonymous contact or a named user. Airship can set targeting data on these identifiers, which are also used to map devices and channels to a specific user. For detailed information about contacts and named users, see Named users.
Managing the contact’s identifier (named user ID)
Identify can be called multiple times with the same named user ID. The SDK will automatically deduplicate identify
calls made with the same named user ID. If the ID is changed from a previous value, the contact will automatically
be dissociated from the previous named user ID.
Identifying the contact
Airship.contact.identify("some named user ID")@import AirshipObjectiveC;
[UAirship.contact identify:@"some named user ID"];If the user logs out of the device, you may want to reset the contact. This will clear any anonymous data and dissociate the contact from the named user ID, if set. This should only be called when the user manually logs out of the app, otherwise you will not be able to target the channel by its contact data.
Resetting the contact
Airship.contact.reset()@import AirshipObjectiveC;
[UAirship.contact reset];If your app associates the channel with a named user out-of-band, such as through your own backend instead of identify or reset, call notifyRemoteLogin to tell the SDK to refresh its contact data. Only call this when the user’s login has actually changed.
Notifying a remote login
Airship.contact.notifyRemoteLogin()@import AirshipObjectiveC;
[UAirship.contact notifyRemoteLogin];You can get the named user ID only if you set it through the SDK.
Getting the named user ID
await Airship.contact.namedUserID@import AirshipObjectiveC;
[UAirship.contact getNamedUserIDWithCompletionHandler:^(NSString *namedUserID, NSError *error) {
}];Email channel association
When an email address is registered through the SDK, it will be registered for both transactional and commercial emails by default. To change this behavior, you can override the options to request double opt-inA process where users who sign up for messaging must confirm opting in before they can receive messages. for commercial messages.
Associating an email channel
let options = EmailRegistrationOptions.commercialOptions(
transactionalOptedIn: transactionalDate,
commercialOptedIn: commercialDate,
properties: properties
)
Airship.contact.registerEmail("your@example.com", options: options)Email channel registration is not available in Objective-C. Use Swift.
SMS channel association
When an MSISDNA mobile phone number, including country code, in your Airship audience. is registered through the SDK, Airship sends a message to that number, prompting them to opt in. For more information, see the SMS platform documentation: Non-Mobile Double Opt-In.
Associating an SMS channel
let options = SMSRegistrationOptions.optIn(senderID: "senderId")
Airship.contact.registerSMS("yourMsisdn", options: options)SMS channel registration is not available in Objective-C. Use Swift.
Open channel association
Open channels support notifications to any medium that can accept a JSON payload, through either the Airship API or web dashboard. For more information about open channels, see the open channels documentation.
Associating an open channel
let options = OpenRegistrationOptions.optIn(platformName: "platformName", identifiers: identifiers)
Airship.contact.registerOpen("address", options: options)Open channel registration is not available in Objective-C. Use Swift.