大约在3月9日,我同时收到了推送和无声通知,但在3月22日左右,我停止了接收令牌和无声通知。当我创建一个新项目并实现FCM时,我仍然没有收到推送或无声通知,尽管我可以获得令牌。
有没有其他人经历过同样的症状并解决了这个问题?
版本iPad 15.4.1 Xamarin.Firebase.iOS.CloudMessaging 8.10.0
4.7.1中的库正在接收推送通知,但没有接收静音通知;在更新到8.10.0之后,将不再接收推送通知和无声通知。
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{
Console.WriteLine(userInfo);
}
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
Console.WriteLine(userInfo);
}
public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
{
Console.WriteLine(userInfo);
}欢迎任何建议。诚挚的问候。
发布于 2022-04-27 07:43:55
发布于 2022-04-27 06:20:30
使用函数注册的Javascript很糟糕。
坏代码:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
exports.BucketChanged=functions.region("asia-northeast1").storage.object()
.onFinalize(async (object)=>{
const topic = "TopicName";
const message = {
topic: topic,
data: {
body: object.name,
contentAvailable: "true",
},
};
admin.messaging().send(message)
.then((response) => {
console.log("Successfully sent message:", response);
})
.catch((error) => {
console.log("Error sending message", error);
});
}
);好代码:
"use strict";
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
exports.sendSilentNotificationWithTopic = functions.region("asia-northeast1")
.region("asia-northeast1").storage.object().onFinalize(async (object) => {
const topic = "TopicName";
const payload = {
data: {
imageName: object.name,
},
};
const options = {
contentAvailable: true,
};
return admin.messaging().sendToTopic(topic, payload, options)
.then(function(response) {
return console.log("Successfully sent message:", response);
})
.catch(function(error) {
return console.log("Error sending message:", error);
});
});主要是发送和sendToTopic之间的区别,但是谁能解释为什么会发生这种情况呢?至少我现在做得对..。
https://stackoverflow.com/questions/72006758
复制相似问题