Created
May 12, 2020 20:23
-
-
Save javieranton-zz/821455be02cf9e899b98f609152e99d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String token = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken(); | |
| if (token != null) { | |
| com.codename1.io.Preferences.set("pushKey", token); | |
| your.app.namespace.SomeClass.SomeStaticMethod(token); } | |
| //check token is the same after 5 seconds | |
| //cn1's gcm service sometimes gets the wrong token and this is then useful to overwrite it | |
| java.util.Timer timer = new java.util.Timer(); | |
| timer.schedule(new java.util.TimerTask() { | |
| public void run() { | |
| Display.getInstance().callSerially(new Runnable() { | |
| public void run() { | |
| String token = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken(); | |
| if (token != null && !(token).equals(com.codename1.io.Preferences.get("pushKey", ""))) { | |
| com.codename1.io.Preferences.set("pushKey",token); | |
| your.app.namespace.SomeClass.SomeStaticMethod(token); | |
| } | |
| } | |
| }); | |
| } | |
| }, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment