Forum Discussion
Braze SDK: Logged Out/In States & Push States
- 3 months ago
Hello inespais based on your requirement, it is best to use disableSDK on device when a user logs out.
This will stop data collection and any tracking on that specific device. Other devices registered for that user will still work.
When the user login again, then you can use enableSDK to resume the data collection.
ECulle thank you for your response. I would agree that generally the custom attribute identifying whether the user is logged in/out is a good way to approach it, however, in this case that would mean that if you logout from one device, you also stop receiving comms on additional devices where you're still logged in... So ideally I want to find a solution that works on the device-level and doesn't affect the entire user profile (and all other devices associated with it).
Any advice?
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)
- On User Login: Call the changeUser method with the user's ID.
- changeUser("external_id")
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.
Related Content
- 2 years ago
- 2 years ago
- 2 years ago
- 2 years ago