{Message:Not Able to Generate Token Successfully
Information technology's my first time using FCM.
I download a sample from firebase/quickstart-android and I install the FCM Quickstart. Only I can't get whatsoever token from the log even hitting the LOG TOKEN button in the app.
And then I endeavour to transport a message with Firebase panel and set to target my app package name. I got incoming letters.
I want to know can FCM be used?GCM everything is ok.
Solution:
Because I am non an Android developer, just a backend developer. So it takes me some time to solve information technology. In my opinion, at that place`re some bugs in the sample app.
Code:
RegistrationIntentService.coffee
public class RegistrationIntentService extends IntentService { private static last String TAG = "RegIntentService"; public RegistrationIntentService() { super(TAG); } @Override protected void onHandleIntent(Intent intent) { Cord token = FirebaseInstanceId.getInstance().getToken(); Log.i(TAG, "FCM Registration Token: " + token); } }
MyFirebaseInstanceIDService.java
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { private static final Cord TAG = "MyFirebaseIIDService"; /** * Called if InstanceID token is updated. This may occur if the security of * the previous token had been compromised. Note that this is called when the InstanceID token * is initially generated and so this is where you would think the token. */ // [START refresh_token] @Override public void onTokenRefresh() { // Get updated InstanceID token. // String refreshedToken = FirebaseInstanceId.getInstance().getToken(); // Log.d(TAG, "Refreshed token: " + refreshedToken); // // // TODO: Implement this method to send whatever registration to your app's servers. // sendRegistrationToServer(refreshedToken); // Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } // [END refresh_token] /** * Persist token to third-party servers. * <p> * Modify this method to acquaintance the user's FCM InstanceID token with any server-side account * maintained past your application. * * @param token The new token. */ private void sendRegistrationToServer(String token) { // Add custom implementation, as needed. } }
Add this in the MainActivity.coffee.
Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent);
After do above,you lot get the Token in Logcat. But finally, I detect a convenient mode to get information technology.Just utilize debug mode to install the sample app and you tin can get the token when you first fourth dimension to install it.
Only I don't know why it can't print the log when I install it. Maybe be related to the mobile organisation.
And then why I can't get the Notification. FirebaseMessagingService.onMessageReceived did non call sendNotification
Source: https://stackoverflow.com/questions/37787373/firebase-fcm-how-to-get-token
0 Response to "{Message:Not Able to Generate Token Successfully"
Postar um comentário