Learn how to collect identity data in a mobile app.
Adobe Experience Platform Identity Service helps you to gain a better view of your customers and their behaviors by bridging identities across devices and systems, allowing you to deliver impactful, personal digital experiences in real time. Identity fields and namespaces are the glue that joins different data sources together to build the 360-degree real-time customer profile.
Learn more about the Identity extension and the identity service in the documentation.
In this lesson, you will:
Begin by updating the user’s identity map when they log in.
Navigate to Login.swift
if the Luma app and find the function called loginButt
.
In the Luma sample app, there is no username or password validation. You simply tap the buttons to “log in”.
Create the IdentityMap
and IdentityItem
.
let identityMap: IdentityMap = IdentityMap()
let emailIdentity = IdentityItem(id: emailAddress, authenticatedState: AuthenticatedState.authenticated)
Add the IdentityItem
to the IdentityMap
identityMap.add(item:emailIdentity, withNamespace: "Email")
Call updateIdentities
to send the data to the Platform Edge Network.
Identity.updateIdentities(with: identityMap)
You can send multiple identities in a single updateIdentities call. You can also modify previously sent identities.
Identity namespaces are components of Identity Service that serve as indicators of the context to which an identity relates. For example, they distinguish a value of “name@email.com” as an email address or “443522” as a numeric CRM ID.
Luma CRM ID
and an Identity symbol value of lumaCrmId
.Now that you’ve created a custom Identity, start collecting it by modifying the updateIdentities
code you added in the previous step. Simply creating an IdentityItem and add it to the IdentityMap. Here is what the full code block should look like:
//Hardcoded identity values
let emailAddress = "testuser@gmail.com"
let crmId = "112ca06ed53d3db37e4cea49cc45b71e"
// Create identity map
let identityMap: IdentityMap = IdentityMap()
// Add email (standard)
let emailIdentity = IdentityItem(id: emailAddress, authenticatedState: AuthenticatedState.authenticated)
identityMap.add(item:emailIdentity, withNamespace: "Email")
// Add lumaCrmId (custom)
let crmIdentity = IdentityItem(id: crmId, authenticatedState: AuthenticatedState.authenticated)
identityMap.add(item: crmIdentity, withNamespace: "lumaCrmId")
// Update
Identity.updateIdentities(with: identityMap)
You can use removeIdentity
to remove the identity from the stored client-side IdentityMap. The Identity extension stops sending the identifier to the Edge Network. Using this API does not remove the identifier from the server-side User Profile Graph or Identity Graph.
Add the following removeIdentity
code to the logout button click in Account.swift
.
// Logout
let logout = UIAlertAction(title: "Logout", style: .destructive, handler: { (action) -> Void in
isLoggedIn = false;
////Hardcoded identity values
let emailAddress = "testuser@gmail.com"
let crmId = "112ca06ed53d3db37e4cea49cc45b71e"
// Adobe Experience Platform - Remove Identity
Identity.removeIdentity(item: IdentityItem(id: emailAddress), withNamespace: "Email")
Identity.removeIdentity(item: IdentityItem(id: crmId), withNamespace: "lumaCrmId")
})
In the above examples, crmId
and emailAddress
are hardcoded but in a real-world app the values would be dynamic.
Review the setup instructions section and connect your simulator or device to Assurance.
In the app, select the Account icon from the bottom right.
Select the Log In button.
You are presented with the option to enter a username & password, both are optional and you can simply select Log In.
Look in the Assurance web UI for the Edge Identity Update Identities
event from the com.adobe.griffon.mobile
vendor.
Select the event and review the data in the ACPExtensionEventData
object. You should see the identities you updated.
Once you complete the steps in the Experience Platform lesson, you will also be able to confirm the identy capture in Platforms identity graph viewer:
Next: Profile
Thank you for investing your time in learning about Adobe Experience Platform Mobile SDK. If you have questions, want to share general feedback, or have suggestions on future content, please share them on this Experience League Community discussion post