CrossGeeks / AzurePushNotificationPlugin

Azure Push Notification Plugin for Xamarin iOS and Android
MIT License
67 stars 34 forks source link

AzurePushNotificationManager.Initialize ResetToken=false #37

Open gmbertolotto opened 4 years ago

gmbertolotto commented 4 years ago

Thanks for your great work, I tried AzurePushNotificationSample and I noticed that in MainApplication.cs AzurePushNotificationManager.Initialize if I set ResetToken = false the registration doesn't happen, if ResetToken = true the registration works. In version 1 everything was working

gmbertolotto commented 4 years ago

ResetToken

rdelrosario commented 4 years ago

If you increment the version number of the app should get registered with ResetToken false

gmbertolotto commented 4 years ago

Thanks again, you're right by changing the version everything works

gmbertolotto commented 4 years ago

I need to activate(create) and deactivate(delete) a single registration without change the app version number. I saw the iOS notification this is ok but with android the re registration is impossible. If I am not wrong on release 1 of your plugin this disable/enable of notification was ok. Thank you

rdelrosario commented 4 years ago

You want to register/unregister from the notification hub? or actually enable/disable push notifications?

gmbertolotto commented 4 years ago

I need to register/unregister from the notification hub, thanks

gmbertolotto commented 4 years ago

On iOS register/unregister from the notification hub is ok, but in android the registration after unregister is not working without an app version increment

rdelrosario commented 4 years ago

Try this beta version:

https://www.nuget.org/packages/Plugin.AzurePushNotification/2.0.32-beta

rdelrosario commented 4 years ago

Let me know if solves your issue

gmbertolotto commented 4 years ago

Notifications.pdf Attached there is a comparison of the entries in azure notification hub using the register/unregister statements of your AzurePushNotificationSample. I have tested the 3 versions (1,2 and beta) of your plugin. thank you

rdelrosario commented 4 years ago

Thanks for this comparison it was helpful. Just released a new beta version let me know if now is fixed:

https://www.nuget.org/packages/Plugin.AzurePushNotification/2.0.33-beta

gmbertolotto commented 4 years ago

I tested the beta version 33 but the results are not the same as in version 1 when the register/unregister operations was correct. Attached the new comparison of versions. Thank you for your time Vers 2.0.33-beta.pdf

IeuanWalker commented 4 years ago

@rdelrosario think I'm getting the same issue.

When debugging to the android emulator and reset token set to true everything works as expected. I can receive a notification when the app is first launched, restart the app set up a new notification and receive that.

But with the reset token set to false, it works on the first launch but fails when I restart the app.

Is there an issue with setting the reset token to true in production? At the moment I am unable to do a release because of this.

IeuanWalker commented 4 years ago

@rdelrosario after some testing debug works completely fine (reset token = true).

But AdHoc build (rest token = false), has an issue with registering new tags. On the first launch, I can set up as many tags as I want and calling the below code after each one is added (i.e. below code is called twice if 2 tags are added) -

await CrossAzurePushNotification.Current.RegisterAsync(SecureUsersData.GetTagsToRegister().ToArray()).ConfigureAwait(false);

But when I close down the app and add a new tag, no error is returned, but notifications won't be received for that tag, but the old tags that were set up on the first launch still works.

eyeveye commented 3 years ago

Hi,

I have encountered the same. It is very random, with the resettoken = true.

First launched it shows on the Registration, image

after I sent a test message: The outcome will be as below: image

And it will dissapear from registration panel image

I am using version 2.1.3

Any help will be much appreciated.

johnn82 commented 2 years ago

Hi There, we are also facing this issue. Looking a the source code I noticed this in the RegisterAsync method:

It unregisters from the Hub using the Token property image

Then it registers to the Hub again using the DeviceToken property image

May it be that the two values: Token and DeviceToken are out of sync when restarting the app? (different value) Looks like that DeviceToken is only populated when the PNMessagingService .OnNewToken is called. Having ResetToken = false prevent Android to generate a new token unless a new version of the app is installed OR you reinstall the app from scratch. This is ok but the RegisterAsync() method should be fixed using the Token OR the DeviceToken being populated with the last version of Token.

I have came up with this fix

image

image

Doing so makes everything working perfectly!