FCM ID vs FCM Token vs APNS Token - firebase

I'm trying to send notification to specific users on my cordova application using cordova-plugin-firebasex which is a fork of cordova-plugin-firebase with fixs and improvement.
I'd like to know what are the differences between FCM Id, FCM Token, and APNS Token, since there is no accurate explication on this.
Also, which one should you use to send push notifications to specifics users, for both Android & iOS.

The notifications are divided in two components:
The device token (APNs) and the Device ID (FCM).
Payload
Within these two components we find various differences:
FCM is sent as JSON payloads and APNS sends either string or dict.
FCM has a payload of 2KB while APNS has a payload of 4KB.
APNS saves 1 notification per App while FCM saves 100 notifications per device.
FCM supports multiple platforms while APNS requires of their proprietary platform.
Acknowledgement can be sent in FCM if using XMPP, but it's not possible on APNS.

Related

Send FCM push notification to sip client app on Android based on pn-param and pn-prid URI Parameters

I want to send push notifications from my PBX/SIP-Server (FreePBX 15/Asterisk 17)
to sip client apps that provide 'pn-provider', 'pn-param' and 'pn-prid' URI Parameters as specified in rfc8599/draft-ietf-sipcore-sip-push-29 during REGISTER sip request, e.g.
xyz#1xx.1xx.2xx.198:9926;transport=TLS;pn-provider=fcm;pn-param=com.mizuvoip.mizudroid.app;pn-prid=dcrpn1TbEW0:APA91bGgK3RV-s7AX-U2...HLoQL1UNgom
What I haven't managed/do NOT understand so far is how to successfully create a push notification with the device token in 'pn-prid' submitted by the sip client app (NOTE: This is a 3rd party(!) app, for which I neither possess a SenderID nor a ServerKey from its linked Firebase project. In my case, I use and tried before with MizuDroid sip client APP for Android.)
Attempts to send a PUSH notification via FCM HTTP REST API using a ServerKey from a Firebase project I have registered before all resulted in
{"multicast_id":2435751791125788205,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
My questions are:
Is it possible to send FCM PUSH notifications to 3rd party(!) apps from which you have already obtained a device token (here: in 'pn-prid' URI parameter)
If answer 1 is yes: What FCM API do I need to use, what data do I need to submit for the purpose and what are the further prerequisites

Firebase Cloud Messaging returns 200 OK for token that has unsubscribed

We use the Firebase Java SDK (com.google.firebase:firebase-admin) to send Push Notifications to iOS and Android devices.
We can successfully construct a notification, and send it to a device using the registered FCM token.
On such a device, we opened System Settings, and disabled push notification for the application.
We sent a new notification using FCM, and it did not appear on the device - as expected.
However, we now expect that the Firebase API should throw an Exception, because the FCM token is no longer valid / has been revoked.
We figured it may be cached for a while, but it has now been over 24 hours. We need to be able to fallback to other delivery methods if push has been disabled on a device.
Why does FCM still return 200 OK?
Disabling notifications for the application does not automatically unregister that application with Firebase Cloud Messaging. If you re-enable notifications to that application, the OS will happily deliver notifications again, and it will (as far as I know) continue to use the same token.

When to use iOS device token when sending push notifications through FCM?

I'm confused about the implementation of cloud messaging through FCM. To send an iOS device a remote (push) notification, an iOS device token is needed for APNs. However, a Firebase app doesn't interface with APNs, it interfaces with FCM, which interfaces with APNs. But to send a push notification (or message) to any client through FCM requires an FCM token. Does this mean that the iOS device token is not needed for a Firebase app to send push notifications to iOS devices?
Only an FCM token is required to send a message to a device. There is no Apple-specific data required. Firebase handles the details of each underlying push notification system.
Firebase uses method swizzling to automatically map your FCM token to your APNs token, as explained in the Firebase Docs here (or see images below).

How Firebase push notification work on IOS?

I want to create my own push notification mechanism for my own iOS applications.
I compared some services like pushy.me or Google Firebase. I think Pushy is the only service that can push notifications independent from Apple APNs, but it uses simple HTTP long-poll requests to receive notifications (in the iOS SDK).
But how does Firebase work? Does it still depend on Apple's APNs? How will it affect my battery life?
Firebase Cloud Messaging (FCM) delivers push notification to iOS devices via Apple's Push Notifications service. Also FCM extends functionality of push notifications.
How FCM extends?
FCM works with iOS and Android. Cool feature if you have the app for both platforms;
Don't need to develop backend for sending notifications, storing pn tokens etc. Just register your app in the Google Developer Console and follow User Guides. For sending a push just execute request to https://fcm.googleapis.com/fcm/send with params;
Broadcast notifications. The app subscribes to a topic and then you can send a notification to all topic subscribers. Very cool;
Upstream messages (send data to the server)
Also Google has others services you can extend FCM with. For example Cloud Functions.
I didn't find that FCM integration take big affect to battery life in my apps.
UPDATE:
FCM framework sends push notification token (and other info) to Google services. Also as I mentioned above you can subscribe app for a specific topic. Than Google knows which device needs to send a push to.
There is a possibility to setup FCM in iOS automatically(with using method swizzling). FCM exchange AppDelegate methods and knows your's device pn token.
Firebase Cloud Messaging (FCM) utilizes APNs (Apple push notifications services) for delivering the messages to iOS devices.
So basically, FCM wraps iOS methods like registerForRemoteNotifications or didReceiveRemoteNotification using method swizzling (BTW, you can disable this if you wish, although I can't see any reason...).
On the technical side - the phone is keeping an open connection with APNs and this tunnel is used for sending the messages themselves.

Sending push notification to existing gcm user from fcm on web

I imported my gcm project to fcm. How can I send push notification to the existing users of GCM? I am using it for web notifications. Everywhere I got the support for android and IOS. How to sent notifications on chrome using the gcm ID?
Your question is related to this SO post.
So, it is said that FCM and GCM messaging api are the same. The difference is just their url, GCM - gcm-http.googleapis.com/gcm/ and FCM - fcm.googleapis.com/fcm/ and still pointing to same server.
Furthermore, you can see this documentation about Update server endpoints
You can also refer to this SO post for further reading.

Resources