I recently integrated App Center Push into my Xamarin.Forms app for iOS/Android.
In my app, users are initially presented with a login page. On login, I use AppCenter.SetUserID("username") to identify them with App Center. This lets me send push notifications via App Center by just sending "Send this to [email protected]". If Alex has 5 phones and 5 tablets all logged in at the same time, this is no problem because I only need to send 1 push notification and it goes to all of them. I regularly send push notifications for my chat-like app when the app is in the background. I need users to know a new message is waiting for them.
The problem comes when a user logs out. You can't clear or change the device install ID because its set in stone on app installation. So the user logs out, but they're still getting push notifications meant for "[email protected]". One theory I had was to change/scramble the username upon clicking logout like AppCenter.SetUserID("asdfasdf96fa98sfa98s76f59as8f"). Unfortunately this doesn't seem to break the "link" between the device install ID and the previous username. No matter what you try to set username to, the old install ID still remains and thus you continue receiving notifications for that user. Even if you log in as a completely different person, you keep getting the previous login's stuff.
So I guess I am confused what the point of App Center Push's "push to specific users" functionality is. It seems to me like my only option is to resort to having to catalog every single Device Install ID in a database on my server. I have to be responsible for keeping a mapping of IDs-to-usernames, and then spam them all at the same time when I need to run a push notification. So what I find myself doing is creating a SQL table like "tblMobilePush" where I have 1 row per Device Install ID, and then a field to say which username that device belongs to. When I want to send something, I have to say "grab all IDs where username = "[email protected]". Then somehow I have to know to remove or expire IDs that are dead... which means I need to call a "logout" API to erase it when someone clicks "logout". But what if someone doesn't click "logout" and they just uninstall instead?
Is any of this accurate? Is there a better way to do this? Is App Center Push the service I should be using?
I appreciate any advice as I've been scratching my head about this for a while...