larpon / QtFirebaseExample

Example Qt app for the QtFirebase project
MIT License
39 stars 28 forks source link

generate new token #21

Open GregoryError opened 5 years ago

GregoryError commented 5 years ago

I got now token from overrided java method "onNewToken" in the class ListenerService extends FirebaseMessagingService. But I cant figure out how to refresh token. For example when my user log out and log in again as another user I have to use new token for him. So how to get a new token without instaling the app as a new? maybe I have to call same method in class Main that extends QtActivity?

larpon commented 5 years ago

Hmm... I'm not sure. What does the firebaee documentation say?

GregoryError commented 5 years ago

@Larpon it says that: The registration token may change when:

The app deletes Instance ID

The app is restored on a new device

The user uninstalls/reinstall the app

The user clears app data.

I was thinking about something like deleting cache programmatically but encountered with some issues with threads in Qt. What about first "deletes Instance ID"? Is it possible? What does it mean?

larpon commented 5 years ago

The InstanceID is probably this. I guess it currently has the same life-cycle as the application and will get deleted when the ::App is deleted.

I'm not aware of any code right now that handles multiple instances. But in theory it should be possible to shutdown an instance and bring up a new one - assuming no code is calling anything on the instance - this can be very difficult to detect with QML as it's garbage collected.