What is FCM token in Firebase?2019 Community Moderator ElectionFirebase Cloud Messaging using Web API C#FCMToken and deviceTokenIssue with getting Registration ID from Firebase Cloud MessagingFirebase FCM force onTokenRefresh() to be calledFirebase Cloud Messaging - Handling logoutGoogle GCM, token vs registration idFCM token missingIs FCM token refreshed on app update?FCM: onNewToken vs FirebaseInstanceIdFirebase Android Authentication failed: expired_token (Auth token is expired)What is the difference between “px”, “dip”, “dp” and “sp”?How can I send a Firebase Cloud Messaging notification without use the Firebase Console?Firebase (FCM) how to get tokenFirebase (FCM) Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001Group Firebase FCM on Android DeviceRemove FCM token from Firebase device groupHow to detect if token is expired or not registred firebase FCM notification on app server?Firebase Notification To Device with FCM Token Says Sent but not receivedfcm registration token stored automatically into firebase databaseFirebase FCM error: Unregistered registration token

PTIJ: Why does only a Shor Tam ask at the Seder, and not a Shor Mu'ad?

What would be the most expensive material to an intergalactic society?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Why does cron require MTA for logging?

How do we create new idioms and use them in a novel?

What is Tony Stark injecting into himself in Iron Man 3?

Can't make sense of a paragraph from Lovecraft

How to resolve: Reviewer #1 says remove section X vs. Reviewer #2 says expand section X

Are small insurances worth it?

Why is a very small peak with larger m/z not considered to be the molecular ion?

Is a piano played in the same way as a harmonium?

Are all players supposed to be able to see each others' character sheets?

Shifting between bemols and diesis in the key signature

Vocabulary for giving just numbers, not a full answer

Is it a Cyclops number? "Nobody" knows!

What will be the sign of work done?

Confusion about Complex Continued Fraction

Expressing logarithmic equations without logs

Palindrome Fibonacci words

ER diagram relationship node size adjustment

The meaning of ‘otherwise’

Finitely many repeated replacements

What sort of fish is this

What is the generally accepted pronunciation of “topoi”?



What is FCM token in Firebase?



2019 Community Moderator ElectionFirebase Cloud Messaging using Web API C#FCMToken and deviceTokenIssue with getting Registration ID from Firebase Cloud MessagingFirebase FCM force onTokenRefresh() to be calledFirebase Cloud Messaging - Handling logoutGoogle GCM, token vs registration idFCM token missingIs FCM token refreshed on app update?FCM: onNewToken vs FirebaseInstanceIdFirebase Android Authentication failed: expired_token (Auth token is expired)What is the difference between “px”, “dip”, “dp” and “sp”?How can I send a Firebase Cloud Messaging notification without use the Firebase Console?Firebase (FCM) how to get tokenFirebase (FCM) Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001Group Firebase FCM on Android DeviceRemove FCM token from Firebase device groupHow to detect if token is expired or not registred firebase FCM notification on app server?Firebase Notification To Device with FCM Token Says Sent but not receivedfcm registration token stored automatically into firebase databaseFirebase FCM error: Unregistered registration token










34















In the new Firebase, under Notification, they have mentioned that developer can send notification to a particular device. For that, in console it asks for an FCM token. What is it exactly and how can I get that token?










share|improve this question




























    34















    In the new Firebase, under Notification, they have mentioned that developer can send notification to a particular device. For that, in console it asks for an FCM token. What is it exactly and how can I get that token?










    share|improve this question


























      34












      34








      34


      11






      In the new Firebase, under Notification, they have mentioned that developer can send notification to a particular device. For that, in console it asks for an FCM token. What is it exactly and how can I get that token?










      share|improve this question
















      In the new Firebase, under Notification, they have mentioned that developer can send notification to a particular device. For that, in console it asks for an FCM token. What is it exactly and how can I get that token?







      android firebase firebase-cloud-messaging firebase-notifications






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 7 '16 at 6:25









      AL.

      24.3k857191




      24.3k857191










      asked Jun 7 '16 at 5:43









      arunrkarunrk

      193129




      193129






















          5 Answers
          5






          active

          oldest

          votes


















          48














          What is it exactly?



          An FCM Token, or much commonly known as a registrationToken like in google-cloud-messaging. As described in the GCM docs:




          An ID issued by the GCM connection servers to the client app that allows it to receive messages. Note that registration tokens must be kept secret.





          How can I get that token?



          Update: The token can still be retrieved by calling getToken(), however, as per FCM's latest version, the FirebaseInstanceIdService.onTokenRefresh() has been replaced with FirebaseMessagingService.onNewToken() -- which in my experience functions the same way as onTokenRefresh() did.




          Old answer:



          As per the FCM docs:




          On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token.



          You can access the token's value by extending FirebaseInstanceIdService. Make sure you have added the service to your manifest, then call getToken in the context of onTokenRefresh, and log the value as shown:



          @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 any registration to your app's servers.
          sendRegistrationToServer(refreshedToken);



          The onTokenRefreshcallback fires whenever a new token is generated, so calling getToken in its context ensures that you are accessing a current, available registration token. FirebaseInstanceID.getToken() returns null if the token has not yet been generated.



          After you've obtained the token, you can send it to your app server and store it using your preferred method. See the Instance ID API reference for full detail on the API.







          share|improve this answer




















          • 1





            When that FCM token get generate for the first time? Does firebase authentication is need like firebase storage?

            – arunrk
            Jun 7 '16 at 6:25












          • The registrationToken usually gets generated for the first time whenever the app is first installed. And when following the usual process. You have to send the generated registrationToken to your app server. Sorry, but can you elaborate on Does firebase authentication is need like firebase storage ?

            – AL.
            Jun 7 '16 at 6:36







          • 1





            @arunrk - i recommend you to go through this : github.com/firebase/quickstart-android/tree/master/messaging

            – AnhSirk Dasarp
            Jun 7 '16 at 6:42






          • 1





            @AL we'll soon revert to calling that value a server key, since calling it a token just introduces more confusion. The OP here was clearly asking about a client-device token, so I wouldn't talk about the server key/token here.

            – Frank van Puffelen
            Nov 25 '16 at 4:57






          • 1





            @Al Thanks alot .. actually in ios u need both Device token and registration token to make a successfull push notification call from server side. So we tested it with only the token recived in onTokenRefreshed() and tinggg!! it worked

            – Adeel Turk
            Mar 22 '17 at 10:06



















          5














          Here is simple steps
          add this gradle:



          dependencies 
          compile "com.google.firebase:firebase-messaging:9.0.0"



          No extra permission are needed in manifest like GCM.
          No receiver is needed to manifest like GCM. With FCM, com.google.android.gms.gcm.GcmReceiver is added automatically.



          Migrate your listener service



          A service extending InstanceIDListenerService is now required only if you want to access the FCM token.



          This is needed if you want to



          • Manage device tokens to send a messages to single device directly, or
            Send messages to device group, or

          • Send messages to device group, or

          • Subscribe devices to topics with the server subscription management API.

          Add Service in manifest



          <service
          android:name=".MyInstanceIDListenerService">
          <intent-filter>
          <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
          </intent-filter>
          </service>

          <service
          android:name=".MyFirebaseInstanceIDService">
          <intent-filter>
          <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
          </intent-filter>
          </service>


          Change MyInstanceIDListenerService to extend FirebaseInstanceIdService, and update code to listen for token updates and get the token whenever a new token is generated.



          public class MyInstanceIDListenerService extends FirebaseInstanceIdService 

          ...

          /**
          * Called if InstanceID token is updated. This may occur if the security of
          * the previous token had been compromised. Note that this is also called
          * when the InstanceID token is initially generated, so this is where
          * you retrieve 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 any registration to your app's servers.
          sendRegistrationToServer(refreshedToken);





          For more information visit



          1. How to import former GCM Projects into Firebase

          2. How to force a token refresh

          3. How to access the token

          4. How to set up firebase





          share|improve this answer
































            3














            FirebaseInstanceIdService is now deprecated. you should get the Token in the onNewToken method in the FirebaseMessagingService.



            Check out the docs






            share|improve this answer






























              2














              I have an update about "Firebase Cloud Messaging token" which I could get an information.



              I really wanted to know about that change so just sent a mail to Support team. The Firebase Cloud Messaging token will get back to Server key soon again. There will be nothing to change. We can see Server key again after soon.






              share|improve this answer

























              • All that will change is the label in the Cloud Messaging panel of the Project Settings. The value will remain as you see it now. Sorry about any confusion the new label may have caused.

                – Frank van Puffelen
                Nov 25 '16 at 15:36


















              2














              They deprecated getToken() method in the below release notes. Instead, we have to use getInstanceId.



              https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId



              Task<InstanceIdResult> task = FirebaseInstanceId.getInstance().getInstanceId();
              task.addOnSuccessListener(new OnSuccessListener<InstanceIdResult>()
              @Override
              public void onSuccess(InstanceIdResult authResult)
              // Task completed successfully
              // ...
              String fcmToken = authResult.getToken();

              );

              task.addOnFailureListener(new OnFailureListener()
              @Override
              public void onFailure(@NonNull Exception e)
              // Task failed with an exception
              // ...

              );


              To handle success and failure in the same listener, attach an OnCompleteListener:



              task.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() 
              @Override
              public void onComplete(@NonNull Task<InstanceIdResult> task)
              if (task.isSuccessful())
              // Task completed successfully
              InstanceIdResult authResult = task.getResult();
              String fcmToken = authResult.getToken();
              else
              // Task failed with an exception
              Exception exception = task.getException();


              );


              Also, the FirebaseInstanceIdService Class is deprecated and they came up with onNewToken method in FireBaseMessagingService as replacement for onTokenRefresh,



              you can refer to the release notes here,
              https://firebase.google.com/support/release-notes/android



              @Override
              public void onNewToken(String s)
              super.onNewToken(s);
              Use this code logic to send the info to your server.
              //sendRegistrationToServer(s);






              share|improve this answer























                protected by rene Dec 9 '17 at 10:25



                Thank you for your interest in this question.
                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                Would you like to answer one of these unanswered questions instead?














                5 Answers
                5






                active

                oldest

                votes








                5 Answers
                5






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                48














                What is it exactly?



                An FCM Token, or much commonly known as a registrationToken like in google-cloud-messaging. As described in the GCM docs:




                An ID issued by the GCM connection servers to the client app that allows it to receive messages. Note that registration tokens must be kept secret.





                How can I get that token?



                Update: The token can still be retrieved by calling getToken(), however, as per FCM's latest version, the FirebaseInstanceIdService.onTokenRefresh() has been replaced with FirebaseMessagingService.onNewToken() -- which in my experience functions the same way as onTokenRefresh() did.




                Old answer:



                As per the FCM docs:




                On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token.



                You can access the token's value by extending FirebaseInstanceIdService. Make sure you have added the service to your manifest, then call getToken in the context of onTokenRefresh, and log the value as shown:



                @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 any registration to your app's servers.
                sendRegistrationToServer(refreshedToken);



                The onTokenRefreshcallback fires whenever a new token is generated, so calling getToken in its context ensures that you are accessing a current, available registration token. FirebaseInstanceID.getToken() returns null if the token has not yet been generated.



                After you've obtained the token, you can send it to your app server and store it using your preferred method. See the Instance ID API reference for full detail on the API.







                share|improve this answer




















                • 1





                  When that FCM token get generate for the first time? Does firebase authentication is need like firebase storage?

                  – arunrk
                  Jun 7 '16 at 6:25












                • The registrationToken usually gets generated for the first time whenever the app is first installed. And when following the usual process. You have to send the generated registrationToken to your app server. Sorry, but can you elaborate on Does firebase authentication is need like firebase storage ?

                  – AL.
                  Jun 7 '16 at 6:36







                • 1





                  @arunrk - i recommend you to go through this : github.com/firebase/quickstart-android/tree/master/messaging

                  – AnhSirk Dasarp
                  Jun 7 '16 at 6:42






                • 1





                  @AL we'll soon revert to calling that value a server key, since calling it a token just introduces more confusion. The OP here was clearly asking about a client-device token, so I wouldn't talk about the server key/token here.

                  – Frank van Puffelen
                  Nov 25 '16 at 4:57






                • 1





                  @Al Thanks alot .. actually in ios u need both Device token and registration token to make a successfull push notification call from server side. So we tested it with only the token recived in onTokenRefreshed() and tinggg!! it worked

                  – Adeel Turk
                  Mar 22 '17 at 10:06
















                48














                What is it exactly?



                An FCM Token, or much commonly known as a registrationToken like in google-cloud-messaging. As described in the GCM docs:




                An ID issued by the GCM connection servers to the client app that allows it to receive messages. Note that registration tokens must be kept secret.





                How can I get that token?



                Update: The token can still be retrieved by calling getToken(), however, as per FCM's latest version, the FirebaseInstanceIdService.onTokenRefresh() has been replaced with FirebaseMessagingService.onNewToken() -- which in my experience functions the same way as onTokenRefresh() did.




                Old answer:



                As per the FCM docs:




                On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token.



                You can access the token's value by extending FirebaseInstanceIdService. Make sure you have added the service to your manifest, then call getToken in the context of onTokenRefresh, and log the value as shown:



                @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 any registration to your app's servers.
                sendRegistrationToServer(refreshedToken);



                The onTokenRefreshcallback fires whenever a new token is generated, so calling getToken in its context ensures that you are accessing a current, available registration token. FirebaseInstanceID.getToken() returns null if the token has not yet been generated.



                After you've obtained the token, you can send it to your app server and store it using your preferred method. See the Instance ID API reference for full detail on the API.







                share|improve this answer




















                • 1





                  When that FCM token get generate for the first time? Does firebase authentication is need like firebase storage?

                  – arunrk
                  Jun 7 '16 at 6:25












                • The registrationToken usually gets generated for the first time whenever the app is first installed. And when following the usual process. You have to send the generated registrationToken to your app server. Sorry, but can you elaborate on Does firebase authentication is need like firebase storage ?

                  – AL.
                  Jun 7 '16 at 6:36







                • 1





                  @arunrk - i recommend you to go through this : github.com/firebase/quickstart-android/tree/master/messaging

                  – AnhSirk Dasarp
                  Jun 7 '16 at 6:42






                • 1





                  @AL we'll soon revert to calling that value a server key, since calling it a token just introduces more confusion. The OP here was clearly asking about a client-device token, so I wouldn't talk about the server key/token here.

                  – Frank van Puffelen
                  Nov 25 '16 at 4:57






                • 1





                  @Al Thanks alot .. actually in ios u need both Device token and registration token to make a successfull push notification call from server side. So we tested it with only the token recived in onTokenRefreshed() and tinggg!! it worked

                  – Adeel Turk
                  Mar 22 '17 at 10:06














                48












                48








                48







                What is it exactly?



                An FCM Token, or much commonly known as a registrationToken like in google-cloud-messaging. As described in the GCM docs:




                An ID issued by the GCM connection servers to the client app that allows it to receive messages. Note that registration tokens must be kept secret.





                How can I get that token?



                Update: The token can still be retrieved by calling getToken(), however, as per FCM's latest version, the FirebaseInstanceIdService.onTokenRefresh() has been replaced with FirebaseMessagingService.onNewToken() -- which in my experience functions the same way as onTokenRefresh() did.




                Old answer:



                As per the FCM docs:




                On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token.



                You can access the token's value by extending FirebaseInstanceIdService. Make sure you have added the service to your manifest, then call getToken in the context of onTokenRefresh, and log the value as shown:



                @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 any registration to your app's servers.
                sendRegistrationToServer(refreshedToken);



                The onTokenRefreshcallback fires whenever a new token is generated, so calling getToken in its context ensures that you are accessing a current, available registration token. FirebaseInstanceID.getToken() returns null if the token has not yet been generated.



                After you've obtained the token, you can send it to your app server and store it using your preferred method. See the Instance ID API reference for full detail on the API.







                share|improve this answer















                What is it exactly?



                An FCM Token, or much commonly known as a registrationToken like in google-cloud-messaging. As described in the GCM docs:




                An ID issued by the GCM connection servers to the client app that allows it to receive messages. Note that registration tokens must be kept secret.





                How can I get that token?



                Update: The token can still be retrieved by calling getToken(), however, as per FCM's latest version, the FirebaseInstanceIdService.onTokenRefresh() has been replaced with FirebaseMessagingService.onNewToken() -- which in my experience functions the same way as onTokenRefresh() did.




                Old answer:



                As per the FCM docs:




                On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token.



                You can access the token's value by extending FirebaseInstanceIdService. Make sure you have added the service to your manifest, then call getToken in the context of onTokenRefresh, and log the value as shown:



                @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 any registration to your app's servers.
                sendRegistrationToServer(refreshedToken);



                The onTokenRefreshcallback fires whenever a new token is generated, so calling getToken in its context ensures that you are accessing a current, available registration token. FirebaseInstanceID.getToken() returns null if the token has not yet been generated.



                After you've obtained the token, you can send it to your app server and store it using your preferred method. See the Instance ID API reference for full detail on the API.








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 17 '18 at 11:18

























                answered Jun 7 '16 at 5:58









                AL.AL.

                24.3k857191




                24.3k857191







                • 1





                  When that FCM token get generate for the first time? Does firebase authentication is need like firebase storage?

                  – arunrk
                  Jun 7 '16 at 6:25












                • The registrationToken usually gets generated for the first time whenever the app is first installed. And when following the usual process. You have to send the generated registrationToken to your app server. Sorry, but can you elaborate on Does firebase authentication is need like firebase storage ?

                  – AL.
                  Jun 7 '16 at 6:36







                • 1





                  @arunrk - i recommend you to go through this : github.com/firebase/quickstart-android/tree/master/messaging

                  – AnhSirk Dasarp
                  Jun 7 '16 at 6:42






                • 1





                  @AL we'll soon revert to calling that value a server key, since calling it a token just introduces more confusion. The OP here was clearly asking about a client-device token, so I wouldn't talk about the server key/token here.

                  – Frank van Puffelen
                  Nov 25 '16 at 4:57






                • 1





                  @Al Thanks alot .. actually in ios u need both Device token and registration token to make a successfull push notification call from server side. So we tested it with only the token recived in onTokenRefreshed() and tinggg!! it worked

                  – Adeel Turk
                  Mar 22 '17 at 10:06













                • 1





                  When that FCM token get generate for the first time? Does firebase authentication is need like firebase storage?

                  – arunrk
                  Jun 7 '16 at 6:25












                • The registrationToken usually gets generated for the first time whenever the app is first installed. And when following the usual process. You have to send the generated registrationToken to your app server. Sorry, but can you elaborate on Does firebase authentication is need like firebase storage ?

                  – AL.
                  Jun 7 '16 at 6:36







                • 1





                  @arunrk - i recommend you to go through this : github.com/firebase/quickstart-android/tree/master/messaging

                  – AnhSirk Dasarp
                  Jun 7 '16 at 6:42






                • 1





                  @AL we'll soon revert to calling that value a server key, since calling it a token just introduces more confusion. The OP here was clearly asking about a client-device token, so I wouldn't talk about the server key/token here.

                  – Frank van Puffelen
                  Nov 25 '16 at 4:57






                • 1





                  @Al Thanks alot .. actually in ios u need both Device token and registration token to make a successfull push notification call from server side. So we tested it with only the token recived in onTokenRefreshed() and tinggg!! it worked

                  – Adeel Turk
                  Mar 22 '17 at 10:06








                1




                1





                When that FCM token get generate for the first time? Does firebase authentication is need like firebase storage?

                – arunrk
                Jun 7 '16 at 6:25






                When that FCM token get generate for the first time? Does firebase authentication is need like firebase storage?

                – arunrk
                Jun 7 '16 at 6:25














                The registrationToken usually gets generated for the first time whenever the app is first installed. And when following the usual process. You have to send the generated registrationToken to your app server. Sorry, but can you elaborate on Does firebase authentication is need like firebase storage ?

                – AL.
                Jun 7 '16 at 6:36






                The registrationToken usually gets generated for the first time whenever the app is first installed. And when following the usual process. You have to send the generated registrationToken to your app server. Sorry, but can you elaborate on Does firebase authentication is need like firebase storage ?

                – AL.
                Jun 7 '16 at 6:36





                1




                1





                @arunrk - i recommend you to go through this : github.com/firebase/quickstart-android/tree/master/messaging

                – AnhSirk Dasarp
                Jun 7 '16 at 6:42





                @arunrk - i recommend you to go through this : github.com/firebase/quickstart-android/tree/master/messaging

                – AnhSirk Dasarp
                Jun 7 '16 at 6:42




                1




                1





                @AL we'll soon revert to calling that value a server key, since calling it a token just introduces more confusion. The OP here was clearly asking about a client-device token, so I wouldn't talk about the server key/token here.

                – Frank van Puffelen
                Nov 25 '16 at 4:57





                @AL we'll soon revert to calling that value a server key, since calling it a token just introduces more confusion. The OP here was clearly asking about a client-device token, so I wouldn't talk about the server key/token here.

                – Frank van Puffelen
                Nov 25 '16 at 4:57




                1




                1





                @Al Thanks alot .. actually in ios u need both Device token and registration token to make a successfull push notification call from server side. So we tested it with only the token recived in onTokenRefreshed() and tinggg!! it worked

                – Adeel Turk
                Mar 22 '17 at 10:06






                @Al Thanks alot .. actually in ios u need both Device token and registration token to make a successfull push notification call from server side. So we tested it with only the token recived in onTokenRefreshed() and tinggg!! it worked

                – Adeel Turk
                Mar 22 '17 at 10:06














                5














                Here is simple steps
                add this gradle:



                dependencies 
                compile "com.google.firebase:firebase-messaging:9.0.0"



                No extra permission are needed in manifest like GCM.
                No receiver is needed to manifest like GCM. With FCM, com.google.android.gms.gcm.GcmReceiver is added automatically.



                Migrate your listener service



                A service extending InstanceIDListenerService is now required only if you want to access the FCM token.



                This is needed if you want to



                • Manage device tokens to send a messages to single device directly, or
                  Send messages to device group, or

                • Send messages to device group, or

                • Subscribe devices to topics with the server subscription management API.

                Add Service in manifest



                <service
                android:name=".MyInstanceIDListenerService">
                <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
                </intent-filter>
                </service>

                <service
                android:name=".MyFirebaseInstanceIDService">
                <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                </intent-filter>
                </service>


                Change MyInstanceIDListenerService to extend FirebaseInstanceIdService, and update code to listen for token updates and get the token whenever a new token is generated.



                public class MyInstanceIDListenerService extends FirebaseInstanceIdService 

                ...

                /**
                * Called if InstanceID token is updated. This may occur if the security of
                * the previous token had been compromised. Note that this is also called
                * when the InstanceID token is initially generated, so this is where
                * you retrieve 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 any registration to your app's servers.
                sendRegistrationToServer(refreshedToken);





                For more information visit



                1. How to import former GCM Projects into Firebase

                2. How to force a token refresh

                3. How to access the token

                4. How to set up firebase





                share|improve this answer





























                  5














                  Here is simple steps
                  add this gradle:



                  dependencies 
                  compile "com.google.firebase:firebase-messaging:9.0.0"



                  No extra permission are needed in manifest like GCM.
                  No receiver is needed to manifest like GCM. With FCM, com.google.android.gms.gcm.GcmReceiver is added automatically.



                  Migrate your listener service



                  A service extending InstanceIDListenerService is now required only if you want to access the FCM token.



                  This is needed if you want to



                  • Manage device tokens to send a messages to single device directly, or
                    Send messages to device group, or

                  • Send messages to device group, or

                  • Subscribe devices to topics with the server subscription management API.

                  Add Service in manifest



                  <service
                  android:name=".MyInstanceIDListenerService">
                  <intent-filter>
                  <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
                  </intent-filter>
                  </service>

                  <service
                  android:name=".MyFirebaseInstanceIDService">
                  <intent-filter>
                  <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                  </intent-filter>
                  </service>


                  Change MyInstanceIDListenerService to extend FirebaseInstanceIdService, and update code to listen for token updates and get the token whenever a new token is generated.



                  public class MyInstanceIDListenerService extends FirebaseInstanceIdService 

                  ...

                  /**
                  * Called if InstanceID token is updated. This may occur if the security of
                  * the previous token had been compromised. Note that this is also called
                  * when the InstanceID token is initially generated, so this is where
                  * you retrieve 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 any registration to your app's servers.
                  sendRegistrationToServer(refreshedToken);





                  For more information visit



                  1. How to import former GCM Projects into Firebase

                  2. How to force a token refresh

                  3. How to access the token

                  4. How to set up firebase





                  share|improve this answer



























                    5












                    5








                    5







                    Here is simple steps
                    add this gradle:



                    dependencies 
                    compile "com.google.firebase:firebase-messaging:9.0.0"



                    No extra permission are needed in manifest like GCM.
                    No receiver is needed to manifest like GCM. With FCM, com.google.android.gms.gcm.GcmReceiver is added automatically.



                    Migrate your listener service



                    A service extending InstanceIDListenerService is now required only if you want to access the FCM token.



                    This is needed if you want to



                    • Manage device tokens to send a messages to single device directly, or
                      Send messages to device group, or

                    • Send messages to device group, or

                    • Subscribe devices to topics with the server subscription management API.

                    Add Service in manifest



                    <service
                    android:name=".MyInstanceIDListenerService">
                    <intent-filter>
                    <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
                    </intent-filter>
                    </service>

                    <service
                    android:name=".MyFirebaseInstanceIDService">
                    <intent-filter>
                    <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                    </intent-filter>
                    </service>


                    Change MyInstanceIDListenerService to extend FirebaseInstanceIdService, and update code to listen for token updates and get the token whenever a new token is generated.



                    public class MyInstanceIDListenerService extends FirebaseInstanceIdService 

                    ...

                    /**
                    * Called if InstanceID token is updated. This may occur if the security of
                    * the previous token had been compromised. Note that this is also called
                    * when the InstanceID token is initially generated, so this is where
                    * you retrieve 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 any registration to your app's servers.
                    sendRegistrationToServer(refreshedToken);





                    For more information visit



                    1. How to import former GCM Projects into Firebase

                    2. How to force a token refresh

                    3. How to access the token

                    4. How to set up firebase





                    share|improve this answer















                    Here is simple steps
                    add this gradle:



                    dependencies 
                    compile "com.google.firebase:firebase-messaging:9.0.0"



                    No extra permission are needed in manifest like GCM.
                    No receiver is needed to manifest like GCM. With FCM, com.google.android.gms.gcm.GcmReceiver is added automatically.



                    Migrate your listener service



                    A service extending InstanceIDListenerService is now required only if you want to access the FCM token.



                    This is needed if you want to



                    • Manage device tokens to send a messages to single device directly, or
                      Send messages to device group, or

                    • Send messages to device group, or

                    • Subscribe devices to topics with the server subscription management API.

                    Add Service in manifest



                    <service
                    android:name=".MyInstanceIDListenerService">
                    <intent-filter>
                    <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
                    </intent-filter>
                    </service>

                    <service
                    android:name=".MyFirebaseInstanceIDService">
                    <intent-filter>
                    <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                    </intent-filter>
                    </service>


                    Change MyInstanceIDListenerService to extend FirebaseInstanceIdService, and update code to listen for token updates and get the token whenever a new token is generated.



                    public class MyInstanceIDListenerService extends FirebaseInstanceIdService 

                    ...

                    /**
                    * Called if InstanceID token is updated. This may occur if the security of
                    * the previous token had been compromised. Note that this is also called
                    * when the InstanceID token is initially generated, so this is where
                    * you retrieve 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 any registration to your app's servers.
                    sendRegistrationToServer(refreshedToken);





                    For more information visit



                    1. How to import former GCM Projects into Firebase

                    2. How to force a token refresh

                    3. How to access the token

                    4. How to set up firebase






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 23 '17 at 12:18









                    Community

                    11




                    11










                    answered Jun 7 '16 at 6:38









                    Md. Sajedul KarimMd. Sajedul Karim

                    3,1622754




                    3,1622754





















                        3














                        FirebaseInstanceIdService is now deprecated. you should get the Token in the onNewToken method in the FirebaseMessagingService.



                        Check out the docs






                        share|improve this answer



























                          3














                          FirebaseInstanceIdService is now deprecated. you should get the Token in the onNewToken method in the FirebaseMessagingService.



                          Check out the docs






                          share|improve this answer

























                            3












                            3








                            3







                            FirebaseInstanceIdService is now deprecated. you should get the Token in the onNewToken method in the FirebaseMessagingService.



                            Check out the docs






                            share|improve this answer













                            FirebaseInstanceIdService is now deprecated. you should get the Token in the onNewToken method in the FirebaseMessagingService.



                            Check out the docs







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jul 5 '18 at 15:22









                            nirnir

                            1599




                            1599





















                                2














                                I have an update about "Firebase Cloud Messaging token" which I could get an information.



                                I really wanted to know about that change so just sent a mail to Support team. The Firebase Cloud Messaging token will get back to Server key soon again. There will be nothing to change. We can see Server key again after soon.






                                share|improve this answer

























                                • All that will change is the label in the Cloud Messaging panel of the Project Settings. The value will remain as you see it now. Sorry about any confusion the new label may have caused.

                                  – Frank van Puffelen
                                  Nov 25 '16 at 15:36















                                2














                                I have an update about "Firebase Cloud Messaging token" which I could get an information.



                                I really wanted to know about that change so just sent a mail to Support team. The Firebase Cloud Messaging token will get back to Server key soon again. There will be nothing to change. We can see Server key again after soon.






                                share|improve this answer

























                                • All that will change is the label in the Cloud Messaging panel of the Project Settings. The value will remain as you see it now. Sorry about any confusion the new label may have caused.

                                  – Frank van Puffelen
                                  Nov 25 '16 at 15:36













                                2












                                2








                                2







                                I have an update about "Firebase Cloud Messaging token" which I could get an information.



                                I really wanted to know about that change so just sent a mail to Support team. The Firebase Cloud Messaging token will get back to Server key soon again. There will be nothing to change. We can see Server key again after soon.






                                share|improve this answer















                                I have an update about "Firebase Cloud Messaging token" which I could get an information.



                                I really wanted to know about that change so just sent a mail to Support team. The Firebase Cloud Messaging token will get back to Server key soon again. There will be nothing to change. We can see Server key again after soon.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Apr 2 '18 at 10:44









                                stop-cran

                                2,58911933




                                2,58911933










                                answered Nov 21 '16 at 11:05









                                PM11PM11

                                444




                                444












                                • All that will change is the label in the Cloud Messaging panel of the Project Settings. The value will remain as you see it now. Sorry about any confusion the new label may have caused.

                                  – Frank van Puffelen
                                  Nov 25 '16 at 15:36

















                                • All that will change is the label in the Cloud Messaging panel of the Project Settings. The value will remain as you see it now. Sorry about any confusion the new label may have caused.

                                  – Frank van Puffelen
                                  Nov 25 '16 at 15:36
















                                All that will change is the label in the Cloud Messaging panel of the Project Settings. The value will remain as you see it now. Sorry about any confusion the new label may have caused.

                                – Frank van Puffelen
                                Nov 25 '16 at 15:36





                                All that will change is the label in the Cloud Messaging panel of the Project Settings. The value will remain as you see it now. Sorry about any confusion the new label may have caused.

                                – Frank van Puffelen
                                Nov 25 '16 at 15:36











                                2














                                They deprecated getToken() method in the below release notes. Instead, we have to use getInstanceId.



                                https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId



                                Task<InstanceIdResult> task = FirebaseInstanceId.getInstance().getInstanceId();
                                task.addOnSuccessListener(new OnSuccessListener<InstanceIdResult>()
                                @Override
                                public void onSuccess(InstanceIdResult authResult)
                                // Task completed successfully
                                // ...
                                String fcmToken = authResult.getToken();

                                );

                                task.addOnFailureListener(new OnFailureListener()
                                @Override
                                public void onFailure(@NonNull Exception e)
                                // Task failed with an exception
                                // ...

                                );


                                To handle success and failure in the same listener, attach an OnCompleteListener:



                                task.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() 
                                @Override
                                public void onComplete(@NonNull Task<InstanceIdResult> task)
                                if (task.isSuccessful())
                                // Task completed successfully
                                InstanceIdResult authResult = task.getResult();
                                String fcmToken = authResult.getToken();
                                else
                                // Task failed with an exception
                                Exception exception = task.getException();


                                );


                                Also, the FirebaseInstanceIdService Class is deprecated and they came up with onNewToken method in FireBaseMessagingService as replacement for onTokenRefresh,



                                you can refer to the release notes here,
                                https://firebase.google.com/support/release-notes/android



                                @Override
                                public void onNewToken(String s)
                                super.onNewToken(s);
                                Use this code logic to send the info to your server.
                                //sendRegistrationToServer(s);






                                share|improve this answer





























                                  2














                                  They deprecated getToken() method in the below release notes. Instead, we have to use getInstanceId.



                                  https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId



                                  Task<InstanceIdResult> task = FirebaseInstanceId.getInstance().getInstanceId();
                                  task.addOnSuccessListener(new OnSuccessListener<InstanceIdResult>()
                                  @Override
                                  public void onSuccess(InstanceIdResult authResult)
                                  // Task completed successfully
                                  // ...
                                  String fcmToken = authResult.getToken();

                                  );

                                  task.addOnFailureListener(new OnFailureListener()
                                  @Override
                                  public void onFailure(@NonNull Exception e)
                                  // Task failed with an exception
                                  // ...

                                  );


                                  To handle success and failure in the same listener, attach an OnCompleteListener:



                                  task.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() 
                                  @Override
                                  public void onComplete(@NonNull Task<InstanceIdResult> task)
                                  if (task.isSuccessful())
                                  // Task completed successfully
                                  InstanceIdResult authResult = task.getResult();
                                  String fcmToken = authResult.getToken();
                                  else
                                  // Task failed with an exception
                                  Exception exception = task.getException();


                                  );


                                  Also, the FirebaseInstanceIdService Class is deprecated and they came up with onNewToken method in FireBaseMessagingService as replacement for onTokenRefresh,



                                  you can refer to the release notes here,
                                  https://firebase.google.com/support/release-notes/android



                                  @Override
                                  public void onNewToken(String s)
                                  super.onNewToken(s);
                                  Use this code logic to send the info to your server.
                                  //sendRegistrationToServer(s);






                                  share|improve this answer



























                                    2












                                    2








                                    2







                                    They deprecated getToken() method in the below release notes. Instead, we have to use getInstanceId.



                                    https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId



                                    Task<InstanceIdResult> task = FirebaseInstanceId.getInstance().getInstanceId();
                                    task.addOnSuccessListener(new OnSuccessListener<InstanceIdResult>()
                                    @Override
                                    public void onSuccess(InstanceIdResult authResult)
                                    // Task completed successfully
                                    // ...
                                    String fcmToken = authResult.getToken();

                                    );

                                    task.addOnFailureListener(new OnFailureListener()
                                    @Override
                                    public void onFailure(@NonNull Exception e)
                                    // Task failed with an exception
                                    // ...

                                    );


                                    To handle success and failure in the same listener, attach an OnCompleteListener:



                                    task.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() 
                                    @Override
                                    public void onComplete(@NonNull Task<InstanceIdResult> task)
                                    if (task.isSuccessful())
                                    // Task completed successfully
                                    InstanceIdResult authResult = task.getResult();
                                    String fcmToken = authResult.getToken();
                                    else
                                    // Task failed with an exception
                                    Exception exception = task.getException();


                                    );


                                    Also, the FirebaseInstanceIdService Class is deprecated and they came up with onNewToken method in FireBaseMessagingService as replacement for onTokenRefresh,



                                    you can refer to the release notes here,
                                    https://firebase.google.com/support/release-notes/android



                                    @Override
                                    public void onNewToken(String s)
                                    super.onNewToken(s);
                                    Use this code logic to send the info to your server.
                                    //sendRegistrationToServer(s);






                                    share|improve this answer















                                    They deprecated getToken() method in the below release notes. Instead, we have to use getInstanceId.



                                    https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId



                                    Task<InstanceIdResult> task = FirebaseInstanceId.getInstance().getInstanceId();
                                    task.addOnSuccessListener(new OnSuccessListener<InstanceIdResult>()
                                    @Override
                                    public void onSuccess(InstanceIdResult authResult)
                                    // Task completed successfully
                                    // ...
                                    String fcmToken = authResult.getToken();

                                    );

                                    task.addOnFailureListener(new OnFailureListener()
                                    @Override
                                    public void onFailure(@NonNull Exception e)
                                    // Task failed with an exception
                                    // ...

                                    );


                                    To handle success and failure in the same listener, attach an OnCompleteListener:



                                    task.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() 
                                    @Override
                                    public void onComplete(@NonNull Task<InstanceIdResult> task)
                                    if (task.isSuccessful())
                                    // Task completed successfully
                                    InstanceIdResult authResult = task.getResult();
                                    String fcmToken = authResult.getToken();
                                    else
                                    // Task failed with an exception
                                    Exception exception = task.getException();


                                    );


                                    Also, the FirebaseInstanceIdService Class is deprecated and they came up with onNewToken method in FireBaseMessagingService as replacement for onTokenRefresh,



                                    you can refer to the release notes here,
                                    https://firebase.google.com/support/release-notes/android



                                    @Override
                                    public void onNewToken(String s)
                                    super.onNewToken(s);
                                    Use this code logic to send the info to your server.
                                    //sendRegistrationToServer(s);







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Jul 12 '18 at 10:32

























                                    answered Jul 12 '18 at 10:12









                                    Manoj KumarManoj Kumar

                                    197110




                                    197110















                                        protected by rene Dec 9 '17 at 10:25



                                        Thank you for your interest in this question.
                                        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                        Would you like to answer one of these unanswered questions instead?



                                        Popular posts from this blog

                                        Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                                        How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

                                        List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229