Great question! You can not currently clear the
Contact Key once it is set, but there is a simple workaround: set it to a random UUID
You'll want to create the anonymous/unknown ID once and hold on to it to re-use as the consumer logs in/logs out of your application. If you assign a "new" random UUID every time the consumer logs out you'll orphan contacts. I would recommend:
- First launch, create an anonymous UUID and store it locally
- Consumer logs in, set their Contact Key
- Consumer logs out, set the anonymous UUID as the Contact Key
- Repeat steps 2-3 as necessary, but never repeat step 1
On logout you might also consider clearing
Attributes and removing
Tags as necessary.
Also, a Voice of Customer request would be great. The SDK engineers would love to see a simple log in/log out functionality added, but it's got to get on the product road map. That won't happen without your voice.