peerwaya / flutter_voip_push_notification

Flutter VoIP Push Notification - Currently iOS >= 8.0 only
BSD 2-Clause "Simplified" License
28 stars 32 forks source link

Using the FCM token with this plugin #7

Open Easycatchup opened 3 years ago

Easycatchup commented 3 years ago

Hi, I'm trying to use this plugin as described in https://github.com/FirebaseExtended/flutterfire/issues/116#issuecomment-583854658 to send IOS background notifications on IOS but I always get the "BadDeviceToken" error server-side, my guess is that I did not correctly register the token.

I am trying to use the same token as FCM - in general push notifications work fine for me using FCM both on Android and IOS, it's really just IOS background notifications that do not work where I would need this plugin.

Could someone who successfully implemented it share the code on the flutter side to use the same token for FCM and this plugin in a stateless widget?

Thanks, Marcel

VictorUvarov commented 3 years ago

Push notification tokens are not the same as voip notification tokens. They need to be managed seperatley in your database.

Here is an example of using it with curl. You can probably do something similar with FCM

curl -v \
-d '{"aps":{"alert":{"uuid":"982cf533-7b1b-4cf6-a6e0-004aab68c503","incoming_caller_id":"0123456789","incoming_caller_name":"Tester"}}}' \
-H "apns-push-type: voip" \
-H "apns-expiration: 0" \
-H "apns-priority: 0" \
-H "apns-topic: <your app’s bundle ID>.voip" \
--http2 \
--cert ./voip_services.pem \
https://api.sandbox.push.apple.com/3/device/<VoIP device Token for your iPhone>

From Apple docs:

Use the voip push type for notifications that provide information about an incoming Voice-over-IP (VoIP) call. For more information, see Responding to VoIP Notifications from PushKit.

If you set this push type, the apns-topic header field must use your app’s bundle ID with .voip appended to the end. If you’re using certificate-based authentication, you must also register the certificate for VoIP services. The topic is then part of the 1.2.840.113635.100.6.3.4 or 1.2.840.113635.100.6.3.6 extension.

The voip push type is not available on watchOS. It is recommended on macOS, iOS, tvOS, and iPadOS.