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

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

问题描述

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

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

清单文件

<使用权限android:name="android.permission.INTERNET"/><应用机器人:allowBackup="真"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"安卓:supportsRtl="true"android:theme="@style/AppTheme"><activity android:name=".MainActivity"><意图过滤器><action android:name="android.intent.action.MAIN"/><类别 android:name="android.intent.category.LAUNCHER"/></意图过滤器></活动><!--定义服务--><服务android:name=".MyFirebaseMessagingService"><意图过滤器><action android:name="com.google.firebase.MESSAGING_EVENT"/></意图过滤器></服务><服务android:name=".MyFirebaseInstanceIDService"><意图过滤器><action android:name="com.google.firebase.INSTANCE_ID_EVENT"/></意图过滤器></服务></应用程序>

解决方案

请检查是否满足以下所有条件.

<块引用>

  1. 在您的控制台中更新 SHA 1 指纹和软件包名称.
  2. 从开发者控制台放置一个 json 配置文件,并将其放在 app 目录 [模块级目录] 下.
  3. 在 gradle 文件中添加这些行.a) 模块 gradle:应用插件:'com.google.gms.google-services'b) 项目 gradle:类路径 '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天全站免登陆