无法从Firebase控制台发送通知 [英] Failed to send notification from firebase console

查看:317
本文介绍了无法从Firebase控制台发送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个是firebase的一些教程。我正在Firebase注册应用程序,获取google-services.json文件,并将其粘贴到应用程序文件中,如教程中所示。也得到令牌。但是当我试图从控制台发送通知,状态是失败的(我猜MismatchSenderId)。我插入了从 FirebaseInstanceId.getInstance()。getToken(); 获得的相同标记。可能是什么问题?

当我向所有使用该应用程序的设备发送通知时,它也没有成功。

编辑:清单文件


 <! - 添加Internet权限 - > 

<使用权限android:name =android.permission.INTERNET/>
< application
android:allowBackup =true
android:icon =@ mipmap / ic_launcher
android:label =@ string / app_name
android:supportsRtl =true
android:theme =@ style / AppTheme>
< activity android:name =。MainActivity>
< intent-filter>

< category android:name =android.intent.category.LAUNCHER/>
< / intent-filter>
< / activity>

<! -
定义服务
- >
< service
android:name =。MyFirebaseMessagingService>
< intent-filter>
< action android:name =com.google.firebase.MESSAGING_EVENT/>
< / intent-filter>
< / service>

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


解决方案

请检查下列条件是否满足。



  1. 更新您的控制台中的SHA 1指纹和包名称。

  2. 从开发人员控制台放置一个json配置文件,并将其放在应用程序目录[module level directory]下。

  3. 在gradle文件中添加这些行。
    a)模块gradle:apply插件:'com.google.gms.google-services'
    b)项目gradle:classpath'com.google.gms:google-services:3.0.0'


希望它能帮助你...


This is some tutorial of firebase. I'm registering app in Firebase, getting the google-services.json file, pasting it in the app files as shown in the tutorial. Also getting the token. But when I'm trying to send notification from console, the status is failed (I guess MismatchSenderId). I'm inserting the same token that I got from FirebaseInstanceId.getInstance().getToken();. What can be the problem?

p.s. When I send notification to all devices that uses the app, it didn't succeed too.

EDIT: Manifest File

<!-- Adding Internet Permission -->

<uses-permission android:name="android.permission.INTERNET"/>
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!--
        Defining Services
    -->
    <service
        android:name=".MyFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>

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

解决方案

Kindly check if all the below conditions were satisfied.

  1. Update the SHA 1 finger print and package name in your console.
  2. Place a json configuration file from the developer console and place it under app directory [module level directory].
  3. Add these lines in the gradle files. a) Module gradle : apply plugin: 'com.google.gms.google-services' b) Project gradle : classpath 'com.google.gms:google-services:3.0.0'

Hope it helps you...

这篇关于无法从Firebase控制台发送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆