Hey inespais,
Another possible solution would be what you mentioned to create an anonymous profile, but with the consideration that it may create a large amount of useless profiles.
The Technical Implementation:
The entire mechanism hinges on using the changeUser SDK method to manage the association between a device's push token and a user's profile.
- On User Logout: Call the changeUser method with a null value.
- Android (Kotlin): Braze.getInstance().changeUser(null)
- iOS (Swift): Appboy.sharedInstance()?.changeUser(nil)
What this does: This command tells Braze to end the current user's session on that specific device. In the backend, Braze migrates the push token from the identified user's profile to a new, anonymous profile. The logged-in user is no longer associated with that device. - On User Login: Call the changeUser method with the user's ID.
- changeUser("external_id")
What this does: This re-associates the device's push token with the correct user profile, seamlessly restoring their ability to receive targeted pushes on that device.
The Operational Practice:
Because the logged-out device still has a valid push token (now tied to an anonymous profile), it could still receive broadcast campaigns sent to "All Users". The solution is to ensure your campaigns are correctly targeted.
- Apply a filter to your campaign segments: When building campaigns, add a filter to target only known, logged-in users.
- External ID is not blank
By adding this one rule, you ensure messages are only sent to devices that are actively logged into a user account, automatically excluding all logged-out sessions.