简体   繁体   English

如何使用 FCM 向 iOS 发送通知?

[英]How do I send a notification to iOS with FCM?

I am trying to use a firebase cloud function to send notifications to devices.我正在尝试使用 firebase 云 function 向设备发送通知。 My current code is working android devices only.我当前的代码仅适用于 android 设备。 My understanding is that your payload must be special for the iOS device but I am trying to use the sendToDevice function which seems to only be able to take a payload of the notification type.我的理解是,您的有效负载对于 iOS 设备必须是特殊的,但我正在尝试使用 sendToDevice function 似乎只能接收通知类型的有效负载。 Please help with my payload and how to send the notification to the desired token.请帮助我的有效负载以及如何将通知发送到所需的令牌。 My payload and send are as below.我的有效载荷和发送如下。

const payload = admin.messaging.MessagingPayload = {
            notification:{
                title:"You have received a new message!",
                body: fromname + " has messaged you!",
                clickAction: 'FLUTTER_NOTIFICATION_CLICK'
            }
        };

        return admin.messaging().sendToDevice(token,payload);

Have you done APNs (Apple push notification services) setup.您是否完成了 APNs(Apple 推送通知服务)设置。 if not follow this link: https://firebase.google.com/docs/cloud-messaging/ios/certs如果不点击此链接: https://firebase.google.com/docs/cloud-messaging/ios/certs

If you are done with APNS setup then below link will help in setting up firebase PN in flutter如果您已完成 APNS 设置,那么下面的链接将有助于在 flutter 中设置 firebase PN

https://fireship.io/lessons/flutter-push-notifications-fcm-guide/ https://fireship.io/lessons/flutter-push-notifications-fcm-guide/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM