How do I send a notification to iOS with FCM?

2,010

Have you done APNs (Apple push notification services) setup. if not follow this link: 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

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

Share:
2,010
tyler powell
Author by

tyler powell

Updated on December 22, 2022

Comments

  • tyler powell
    tyler powell over 1 year

    I am trying to use a firebase cloud function to send notifications to devices. My current code is working android devices only. 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. 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);