In Firebase, the token is always zero

I am trying to get a token for using cloud messaging in my application with the following simple code:

String token = FirebaseInstanceId.getInstance().getToken();

I tried everywhere to look at StackOverflow for people who had the same problem and couldn't find any solution ... I, of course, followed Google's official installation documentation (several times) and my token was never generated .

Any idea why I can't get a valid token?

Thank!

+4
source share
2 answers

, , , , , , - .

, - , AndroidManifest.xml ( <application>):

tools:node="replace"

:

tools:node="merge"

Firebase . , , , !

, - !

+7

, Firebase " MyFirebaseInstanceIDService.java" "com.company"

, "com.company.services". , google-services.json "com.company".

( )

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

TOKEN public void onTokenRefresh()


PS: , google-services.json .

+2

Source: https://habr.com/ru/post/1656311/


All Articles