Android 无法使Firebase处理通知

Android 无法使Firebase处理通知,android,push-notification,firebase,firebase-cloud-messaging,firebase-notifications,Android,Push Notification,Firebase,Firebase Cloud Messaging,Firebase Notifications,下面我解释了我的示例,并给出了帮助理解该问题的最少代码 到我的gradle档案,最后 apply plugin: 'com.google.gms.google-services' 在我的依赖项{}中,我添加了 compile 'com.google.firebase:firebase-messaging:9.2.0' 我在依赖项{}中也有以下内容 compile 'com.google.android.gms:play-services:9.2.0' compile 'com.google

下面我解释了我的示例,并给出了帮助理解该问题的最少代码

到我的gradle档案,最后

apply plugin: 'com.google.gms.google-services'
在我的依赖项{}中,我添加了

 compile 'com.google.firebase:firebase-messaging:9.2.0'
我在依赖项{}中也有以下内容

compile 'com.google.android.gms:play-services:9.2.0'
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.google.android.gms:play-services-ads:9.2.0'
compile 'com.google.android.gms:play-services-auth:9.2.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
compile 'com.google.android.gms:play-services-analytics:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.maps.android:android-maps-utils:0.4.+'
我有

     <!-- Google Cloud Messaging -->
        <uses-permission
            android:name="com.mcruiseon.buseeta.permission.C2D_MESSAGE"
            android:protectionLevel="signature"/>
        <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

<service android:name=".support.NotificationIncoming">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <service android:name=".support.NotificationsIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>
在我的通知服务中

public class NotificationsIDService extends FirebaseInstanceIdService {
    @Override
    public void onTokenRefresh() {

        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(God.LOG_TAG, "Refreshed token: " + refreshedToken);
        sendRegistrationToServer(refreshedToken);
    }
    private void sendRegistrationToServer(String token) {
        // Add custom implementation, as needed.
    }
}
在Firebase上,我做了以下工作

  • 创建了一个项目
  • 添加了一个SHA1指纹
  • 下载google-services.json并将其复制到app文件夹
  • 我使用与SHA1相同的密钥库构建了一个签名应用程序。然后运行应用程序。然后我从Firebase控制台发送消息

    不走运。我错过了什么?我认为这是非常基本的

    编辑


    对于所有阅读本文的人来说,上面的内容对我来说非常有效。

    没有任何更改,上面的设置/代码开始工作,我很晚才收到这些通知


    @shadab ansari,是的,我确实从下拉列表中添加了应用程序。我还没有从清单中删除权限:),它现在可以工作了,我没有碰它。

    您是否从控制台上的下拉列表中选择应用程序包名称,顺便说一句,不再需要
    ?是的,我已经这样做了。由于某种原因,一大堆通知被延迟收到。这似乎很可笑。。但同样的问题也发生在我身上。它过去可以工作,现在没有更改任何配置、密钥或代码,它已经停止工作。。很奇怪
    public class NotificationsIDService extends FirebaseInstanceIdService {
        @Override
        public void onTokenRefresh() {
    
            String refreshedToken = FirebaseInstanceId.getInstance().getToken();
            Log.d(God.LOG_TAG, "Refreshed token: " + refreshedToken);
            sendRegistrationToServer(refreshedToken);
        }
        private void sendRegistrationToServer(String token) {
            // Add custom implementation, as needed.
        }
    }