无法从Firebase控制台推送通知

时间:2017-02-27 13:37:21

标签: android firebase firebase-cloud-messaging firebase-console

大家好,我从firebase推送通知控制台遇到大问题。我发送通知firebase控制台,但我从来没有收到请帮助我。我无法获得FirebaseInstanceId.getInstance()。getToken();方法。这是我的代码

app / build gradle

-Inf

我的项目/构建gradle

  dependencies {

  compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.android.gms:play-services-drive:10.0.1'
    compile 'com.google.firebase:firebase-appindexing:10.0.1'
    compile 'com.google.android.gms:play-services-places:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.0'
    compile 'com.google.firebase:firebase-database:10.0.0'
    compile 'com.firebaseui:firebase-ui-database:1.0.1'
    compile 'com.google.firebase:firebase-storage:10.0.0'

}
apply plugin: 'com.google.gms.google-services'

我的manifest.xml

 dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    // Add this line
    classpath 'com.google.gms:google-services:3.0.0'

}

我的FirebaseIDService

  <service android:name="com.doa.lojisoft.emd.firebaseservice.MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>

        <service android:name="com.doa.lojisoft.emd.firebaseservice.FirebaseIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>

My MyFirebaseMessagingService.java

 public class FirebaseIDService  extends FirebaseInstanceIdService {

    private static final String TAG = "FirebaseIDService";

    @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);
    }

    /**
     * Persist token to third-party servers.
     *
     * Modify this method to associate the user's FCM InstanceID token with any server-side account
     * maintained by your application.
     *
     * @param token The new token.
     */
    private void sendRegistrationToServer(String token) {
        // Add custom implementation, as needed.
    }
}

0 个答案:

没有答案