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

OnRegistered triggered only one time (after first execution of the App) #29

Closed
aunanue opened this issue Jan 6, 2016 · 4 comments
Closed

Comments

@aunanue
Copy link

aunanue commented Jan 6, 2016

The OnRegistered method is triggered one time and only after deleting the App and installing it again, if I have the App already installed (and being using it) the OnRegistered is not triggered anymore.
Is any way to force it? or tell me if I'm doing something wrong. I have the "Register()" call in the OnStart of the App (Form App).

protected override void OnStart () {
// Handle when your app starts
CrossPushNotification.Current.Register();
}

@aunanue aunanue changed the title OnRegistered only triggered only one time (after first execution of the App) OnRegistered triggered only one time (after first execution of the App) Jan 6, 2016
@rdelrosario
Copy link
Owner

Yes is only trigger one time now because stores the token, if you need it to trigger more than once. should unregister. Why would you want to trigger everytime?

@aunanue
Copy link
Author

aunanue commented Jan 7, 2016

I was expecting to get a new token if that was required. I have this situation:

  1. the plugin returns the token the first time, I store this token on the my DB on the cloud.
  2. with a service on the cloud that has no connection at all with the App I send the Push messages using PushSharp. In some cases the token returned by the plugin expires therefore I need a new one.
  3. at this point I was expecting to receive a new token by the plugin but if I understand properly, I will have to do a sort of communication between the cloud and the App to do the "Plugin.Unregister()" when the PushSharp receives the expired token exception because the plugin does not checks the validity of the current token on the Plugin.Register() method.

In the mean time, can I call the Unregister() followed by the Register()? do you see a problem on this as follows:
protected override void OnStart ()
{
// Handle when your app starts
CrossPushNotification.Current.Unregister();
CrossPushNotification.Current.Register();
}

@MKahmen
Copy link

MKahmen commented Jan 26, 2016

same issue for me. after updating the app in Xamarin Studio, GCM/PushSharp says the device token is expired. I have to either:

  1. uninstall the whole app and reinstall again (which is not a good idea)
  2. call unregister() each time I open the app to make sure the app gets a new token which is not expired (very dirty)

any ideas?

EDIT:
#28

http://stackoverflow.com/questions/11590482/do-gcm-registration-ids-expire

When an application is updated, it should invalidate its existing registration ID, as it is not guaranteed to work with the new version. Because there is no lifecycle method called when the application is updated, the best way to achieve this validation is by storing the current application version when a registration ID is stored.

@rdelrosario
Copy link
Owner

Now calls OnRegistered each time gets registered by Register method

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

No branches or pull requests

3 participants