标签: firebase-cloud-messaging

FCM 中是否有dry_run 功能?

GCM 具有以下dry_run 功能

此参数设置为 true 时,允许开发人员在不实际发送消息的情况下测试请求。

GCM 正在被弃用,以支持FCM,但我在 FCM 中没有看到类似的功能。

FCM 是否允许您进行试运行?

google-cloud-messaging firebase-cloud-messaging

2
推荐指数
1
解决办法
2416
查看次数

FCM Android 通知声音问题

我正在尝试使用 php 向 Android 应用程序发送通知,并且它在没有声音的情况下工作正常。我按预期收到了前台和后台的通知。

这是PHP代码,

<?php


$token = $_GET['token'];
$action = $_GET['action'];
$msgTitle = $_GET['msgTitle'];
$msgDescription = $_GET['msgDescription'];
$notificationTitle = $_GET['notificationTitle'];


require './google-api-php-client-2.2.2/vendor/autoload.php';
$client = new Google_Client();
$client->useApplicationDefaultCredentials(); 
$client->setAuthConfig('./testPrjoectAPP-firebase-adminsdk-9hn21-22c1b3f426.json');
$client->addScope('https://www.googleapis.com/auth/firebase.messaging');
$httpClient = $client->authorize();
$project = "testPrjoectAPP";
$message = [
    "message" => [
        "notification" => [
            "body"  => "Message FCM",
            "title" => $notificationTitle
        ],
        "token" => $token,

       "data" => [
                "action" => $action,
            "msgTitle" => $msgTitle,
            "msgDescription" => $msgDescription 
         ]


    ]
];
$response = $httpClient->post("https://fcm.googleapis.com/v1/projects/{$project}/messages:send", ['json' => $message]);
echo$response->getReasonPhrase(); // …
Run Code Online (Sandbox Code Playgroud)

php android firebase firebase-cloud-messaging

2
推荐指数
1
解决办法
7410
查看次数

APNs 身份验证密钥在 Firebase 中无法用于生产

在开发过程中,我一直在为我的应用成功使用我的 APNs 身份验证密钥。一直很好地接收推送通知,并且所有缩进的行为都在那里。

但是,对于生产(testflight),所有通知都失败了。我一直在努力理解为什么,并假设我在客户端上错误地签名/配置了某些东西(Messaging.messaging().setAPNSToken(deviceToken, type: .prod)但是我确保使用)。

在我绝望的摸索中,我改变了我的 Firebase 配置以使用 APNS Certs,并且由于我以外的原因,我的推送通知已经开始在我的生产环境中工作。

我对 APNs Auth Keys 而不是证书比较陌生,所以我认为我遗漏了一些东西,但是,因为这些傻瓜应该对整个开发者帐户都有好处(对吧?)我完全不知所措什么。

apple-push-notifications ios provisioning-profile swift firebase-cloud-messaging

2
推荐指数
1
解决办法
3008
查看次数

Node.js - FCM 发送预定主题通知

我正在使用 Angular 应用程序和 Node.js 服务器使用 FCM 向 Android 设备发送主题通知。我正在使用公牛来安排通知。

有两种发送通知的方式:立即发送通知和在特定日期和时间发送通知。

要发送通知,我正在使用 Angular 应用程序和此方法:

  sendTopicNotification(notification: Notification): Observable<any> {
    console.log("send topic");
    return this.http.post(endpoint + `notifications/send/topic/topic${notification.target}`, JSON.stringify(notification), httpOptions).pipe(
      map(result => { return true; })
    );
  }
Run Code Online (Sandbox Code Playgroud)

这是我的 Node.js 代码:

const express = require('express');
const router = express.Router();
const fb = require('../firebase/fb');
const db = fb.firestore();
const fcm = fb.messaging();
const moment = require('moment');

var Queue = require('bull');
var notificationsQueue = new Queue('topic notifications', { redis: { port: 6379, host: '127.0.0.1' } …
Run Code Online (Sandbox Code Playgroud)

javascript node.js firebase firebase-cloud-messaging angular

2
推荐指数
1
解决办法
3314
查看次数

主题消息和设备令牌云功能推送通知的区别?

在 Firebase 中,如果用户设备令牌存储在 Firebase 数据库中,则云函数可以向任何用户发送推送通知。同样,如果用户订阅了一个主题,那么另一个用户也可以向该用户发送通知。现在的问题是,在什么情况下我们应该使用主题消息传递,以及在什么情况下我们应该使用云功能来发送通知。如果任何用户订阅了他的唯一 ID(由 Firebase 提供),那么任何人都可以通过将主题消息发布到该唯一 ID 来向他发送主题消息。这是一个好方法还是我们应该使用云功能使用设备令牌向该用户发送推送通知。订阅他自己的唯一ID以获取通知是否是个好主意。请帮我解决我的问题。主题消息可以免费使用吗?

android google-cloud-functions firebase-cloud-messaging

2
推荐指数
1
解决办法
1385
查看次数

尝试向 FCM 服务器进行身份验证时出错

尝试向 FCM 服务器进行身份验证时出错。确保用于验证此 SDK 的凭据具有适当的权限。有关设置说明, 请参阅https://firebase.google.com/docs/admin/setup在此处输入图片说明

push-notification firebase firebase-cloud-messaging

2
推荐指数
5
解决办法
1841
查看次数

Firebase 消息传递 onMessage 仅在窗口中可用

我在我的项目中实现了 Firebase Cloud Messaging 来发送和接收推送通知。我可以接收推送通知,但我无法使通知事件起作用。具体来说,我想让onMessage事件工作,但由于某种原因,它给了我这个错误:

消息传递:此方法在 Window 上下文中可用。(消息/仅在窗口中可用)。

这是我的消息服务工作者:

// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here, other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js')
importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js')

// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
  messagingSenderId: 'XXXXXXXX'
})

// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = …
Run Code Online (Sandbox Code Playgroud)

javascript firebase vue.js firebase-cloud-messaging vuejs2

2
推荐指数
1
解决办法
1493
查看次数

现在禁止旧版 FCM 响应

自周末以来,旧版 FCM 不再有效。

我的设备通过 fcm.googleapis.com/fcm/send 通过旧版 FCM 发送推送通知。我没有改变任何东西,但自周末以来,我收到错误代码“HTTP/1.1 403 Forbidden”。几天后还有其他人有这个问题吗?改变了谷歌的东西?

我用https://www.apnstester.com/fcm/尝试了我的密钥它仍然有效。所以我认为谷歌在 firebase 控制台中改变了一些东西。

编辑:是否可能需要安全访问(https)并且不再支持 http。

BR, 弗洛

legacy firebase firebase-cloud-messaging

2
推荐指数
1
解决办法
1141
查看次数

Ionic 4 + FCM - 如何自定义 Firebase Cloud Messaging (FCM) 通知图标和颜色?

在构建带有FCM 插件的 Ionic 4 应用程序时,一个非常令人沮丧的问题是无法使用自定义颜色设置自定义通知图标。我想出了如何实现这一点,所以只想与我们美丽的 StackOverflow 社区分享解决方案 :)

因此,请在下面的答案中查看自定义 Firebase Cloud Messaging (FCM) 通知图标及其适用于 Android 平台的颜色的解决方案。

ionic-framework notification-icons firebase-cloud-messaging ionic4

2
推荐指数
1
解决办法
3947
查看次数

App crashes after receiving notification using @react-native-firebase/messaging

Iam trying to implement notification using @react-native-firebase/messaging in react native app.The App returns the FCM token ,but when a notification is received the app closes.

I got below error in crashlytics

Unable to instantiate service io.invertase.firebase.messaging.RNFirebaseMessagingService: java.lang.ClassNotFoundException: Didn't find class "io.invertase.firebase.messaging.RNFirebaseMessagingService" on path: DexPathList

Below are the library versions used in app.

"@react-native-firebase/analytics": "^7.6.7",
"@react-native-firebase/app": "^8.4.3",
"@react-native-firebase/crashlytics": "^8.4.9",
"@react-native-firebase/messaging": "^7.8.11",
"react": "16.13.1",
"react-native": "^0.63.3",
Run Code Online (Sandbox Code Playgroud)

android/build.grade

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript …
Run Code Online (Sandbox Code Playgroud)

javascript push-notification firebase react-native firebase-cloud-messaging

2
推荐指数
1
解决办法
2213
查看次数