Open jelmarlaunchlabs opened 7 years ago
I have exactly the same problem...
On Release you shouldn't have this issue. The problem is on debug Android removes and installs the app again.
On Tue, Sep 27, 2016 at 5:12 AM, pug205 notifications@github.com wrote:
I have exactly the same problem...
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rdelrosario/xamarin-plugins/issues/89#issuecomment-249810067, or mute the thread https://github.com/notifications/unsubscribe-auth/ACbgJzxmDaPQks9OaAEHX2M_8tFhdz4Rks5quN3tgaJpZM4KCkE7 .
If it was removing and re-installing then all preferences etc would have been erased. This isn't the case..
Do you have any idea why this is happening other than "because Android removes and installs the app again"?
Yes I've noticed that too, my caches and setting are all preserved when the debugging is restarted and usually it will only be erased when I manually installing and reinstalling the app, something is missing here.
I can reproduce the problem even when I'm not debugging. When I deploy a debug build when the app is not installed on the device, push works. When I force stop the app and start it again, push still works. When I redeploy the app, push no longer works. I was using GCM and I tested against firebase just now, with the same results.
I did some research on Google and found the following thread on the Xamarin forum: https://forums.xamarin.com/discussion/62810/xamarin-android-gcm-notification
"I had also the same issue and started to investigate it. Seems that when you debug deploy again with the same app version, the instanceId isn't valid anymore but gcm doesn't seem to notice this and the token remains the same. When you toggle the appversion (either up or down) everything seems to work fine."
And a code example
[...]
var instanceID = InstanceID.GetInstance (Android.App.Application.Context); // inital call, will maybe get old instanceID
instanceID.DeleteInstanceID (); // force unregistration
instanceID = InstanceID.GetInstance (Android.App.Application.Context); // get a new one
var token = instanceID.GetToken([...])
Hey @pug205
Could you do a PR with this I will merge it once tested.
@pug205 I also have the same problem and sorted out the problem again generating the token on my demo project following this tutorial https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote_notifications_in_android/
but in this xamarin plugin how can I fix this problem, where I can get the code to regenerate the token again?
Any updates on this? This problem seems lurking for a while now.
Should be fixed on:
https://www.nuget.org/packages/Xam.Plugin.PushNotification/1.2.5-beta
I've tried this:
issue only on Android.