When user clear app data it automatically logout but he still get firebase cloud messaging i want to stop sending notifications after user clear app data .
Asked
Active
Viewed 188 times
1 Answers
0
Firebase Cloud Messaging has no concept of users and/or their authentication state, so if your app behavior depends on those it is because you have made a mapping.
For example, it is common to associate the FCM device tokens with the UID of Firebase Authentication, and then look up the FCM device tokens when you want to send a message to that user. If that is indeed what your application does, you'll need to clear that association when the user signs out to stop sending of messages through FCM.
For example, you could check if a specific, known value still exists in the app data every time that your app becomes active, and clear the FCM mapping if that is not the case. Also see:

Frank van Puffelen
- 565,676
- 79
- 828
- 807
-
They suggest to either use mysql (which i don't use i use FBDB) or use shared preference and it's a good idea but if user after cleaning data he didn't use the app i won't be able to check if shared preference is empty – Mohammed Tayeb Aug 15 '22 at 16:31
-
That's correct. I don't think there's any hook that immediately calls your code when the delete happens. You could check in a (scheduled) background service though. – Frank van Puffelen Aug 15 '22 at 16:57