无法从Firebase控制台发送通知

编程入门 行业动态 更新时间:2024-10-22 21:29:33
本文介绍了无法从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>

解决方案

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

  • 更新您的控制台中的SHA 1指纹和包名称。
  • 从开发人员控制台放置一个json配置文件,并将其放在应用程序目录[module level directory]下。
  • 在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.

  • Update the SHA 1 finger print and package name in your console.
  • Place a json configuration file from the developer console and place it under app directory [module level directory].
  • 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控制台发送通知

    本文发布于:2023-10-27 15:56:42,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:控制台   通知   Firebase

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!