Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzurePushNotificationManager.Initialize ResetToken=false #37

Open
gmbertolotto opened this issue Jan 19, 2020 · 16 comments
Open

AzurePushNotificationManager.Initialize ResetToken=false #37

gmbertolotto opened this issue Jan 19, 2020 · 16 comments

Comments

@gmbertolotto
Copy link

gmbertolotto commented Jan 19, 2020

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 gmbertolotto changed the title PushNotificationManager.Initialize ResetToken = false AzurePushNotificationManager.Initialize ResetToken=false Jan 19, 2020
@gmbertolotto
Copy link
Author

ResetToken

@rdelrosario
Copy link
Member

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

@gmbertolotto
Copy link
Author

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

@gmbertolotto
Copy link
Author

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

@gmbertolotto gmbertolotto reopened this Jan 21, 2020
@rdelrosario
Copy link
Member

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

@gmbertolotto
Copy link
Author

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

@gmbertolotto
Copy link
Author

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
Copy link
Member

@rdelrosario
Copy link
Member

Let me know if solves your issue

@gmbertolotto
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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
Copy link

@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
Copy link

@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
Copy link

eyeveye commented May 14, 2021

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
Copy link

johnn82 commented Jan 26, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants