简体   繁体   English

如何在 ios 中设置徽章计数 firebase 推送通知?

[英]How to setup badge count firebase push notification in ios?

I have successfully setup my backend to send notification using "firebase-admin".我已成功设置后端以使用“firebase-admin”发送通知。 However, I am having trouble setting up the badge count for my ios.但是,我无法为我的 ios 设置徽章计数。 I am currently using react native and node.js typescript for backend.我目前正在使用 react native 和 node.js typescript 作为后端。

My backend admin when sending looks like this:发送时我的后端管理员如下所示:

const payload = {
            notification: {
                title: "title",
                body: `body`,
              //badge: 1 this throws an error
            },
            token: receiverFcmToken
        };

        try{
            await admin.messaging().send(payload).then((response) => {
                console.log("success);
            });
        } catch(err){
            console.log(err);
        }

Any help would be appreciated.任何帮助,将不胜感激。 Thanks谢谢

Your payload should look like this:您的有效负载应如下所示:

const payload = {
    notification: {
        title: "title",
        body: `body`,
    },
    apns: {
      payload: {
        aps: {
          badge: 1,
        },
      },
    },
    token: receiverFcmToken
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 打开应用程序后如何删除 react-native-firebase/messaging 中的通知标记计数 - How to remove the notification badge count in react-native-firebase/messaging after opening the app Flutter - 打开应用程序后如何删除 iOS 通知徽章 - Flutter - How to remove iOS notification badge after opening app iOS Firebase 推送通知:如何提供 Firebase 用户的设备令牌并发送通知 - iOS Firebase Push Notifications : How To Give Firebase User's Device Token And Send Notification 如何为 firebase 推送通知添加自定义通知声音 - Flutter - How to add custom notification sound for firebase push notification - Flutter React Native Firebase 推送通知 iOS 真实设备 - React Native Firebase Push Notification iOS Real Device Laravel 推送通知与 Firebase - Laravel Push Notification with Firebase Firebase 网络推送通知 - Firebase Web Push notification 重定向Firebase推送通知 - Redirect Firebase Push notification 无法使用 React-Native-Firebase 接收通过 iOS 中的 Firebase 控制台发送的推送通知 - Unable to receive push notification send via Firebase console in iOS using React-Native-Firebase firebase 推送通知 expo 不工作 - firebase push notification with expo not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM