We used MarketingCloudSDK for our Flutter app, and we created a plugin supporting the push notification and in-app messaging. sfmc_plugin

After user logs in, we set the userId as the contactKey value, and then the user will be able to receiving the push notification and in-app message. However, when user logs out, we found the user will still receive the push notifications and in-app messages.

We tried to find a solution on the documentation but failed.

So, please suggest that where we can find the solution or how we can disable the push notification and in-app message after user logs out for that specific device?

SDK Specifications:

iOS: v7.6

Android: v8.0

1 Answer 1


A common practice involves 2 things:

  1. Create an anonymous ID, like a GUID, when your application is first launched (or after your next update) and hold on to that ID to be used as a logged-out or anonymous user state. When your user logs out, set the Contact Key to this GUID, and, obviously, when they log in set the Contact Key to their "real" ID.

  2. In Android you have a few options for disabling notifications. Each of the discrete types of notifications can be disabled individually on their respective managers, or you can disable notifications system-wide in the Notification Manager class. Those effectively 'hide' the notification from the user, but they are still sent/received on the device. You can also disable push which will opt the user out at the server level and avoid push messages from being delivered. When the user logs in, you'd call enable push to re-opt them into receiving notifications. Finally, as a safety-valve you can use the should show notification interface to apply your own business logic to the display of notifications. You might, for instance, get the SDK's value for contact key and if it is equal to your anonymous GUID you setup then return false to suppress messages. IOS has most of these options, but lacks the discrete controls per-message type.

  • Thanks for the detailed suggestions!
    – Neo Liu
    Commented Oct 4, 2022 at 3:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .