For a new Firebase project I add the SenderId to my desktop websites manifest (and do not use VAPID authentication).
On a successful pushManager.subscription() the token I get back from the pushSubscription is of the format:
https://android.googleapis.com/gcm/send/*instance_token*
I expected it to be using the firebase endpoint instead:
https://fcm.googleapis.com/fcm/send/*instance_token*
I can successfully send push notifications to this token through the firebase endpoint.
My questions are:
Why do I get a GCM endpoint in the token for a firebase project?
Will this always be the case or is something going to change when GCM is discontinued?
Can we continue to use the legacy approach of the gcm_sender_id in the manifest (over VAPID)?
Related
How can I get the device type or operating system from an FCM registration token on my app server, or can I make a post request to my app server with the registration token and user_id?
Reason is, I want to programmatically be able to send messages only to certain usersegments like I can in the firebase console.
Information about the device cannot be extracted from the FCM instance ID token.
You will have to set up your own stream of the information from the client to your servers, where you can then combine it with the FCM token to target users. Not incidentally, this is what Firebase itself does too (through Google Analytics) and is what powers the targeting in the Firebase console.
I have FCM push notifications implemented on a server.
I want to additionally send APNS notifications via that server by sending as a FCM message that is forwarded by Firebase to APNS.
To do that I understand I need to add APNS certificate to the firebase console.
FCM push notifications on my server were implemented some time back when FCM HTTP legacy protocol was available and server API keys were visible in the Firebase console (I got the key from somewhere so I guess it was there).
My question is if I add (and perhaps later remove) an APNS certificate to my firebase console production project will that affect the validity of my existing server API key in any way. It is important that FCM continues to work seamlessly.
It doesn't seem possible to get a FCM HTTP legacy protocol server key now. If there is a way to do this then I could try this myself on a test project.
If I share a user's Firebase device ID key (for a user who has my app installed) with other Firebase service providers, can they send messages from their account (using their authentication key) to a user who has my app installed?
Yes I do realize the process of sharing a user's Firebase device ID key could be problematic. The problem I am trying to solve is that I want multiple providers to be able to send messages to a user who has my app installed.
The Firebase Instance ID (also known as a registration token, or FCM token) identifies an installation of your app on a specific device.
Sending messages to such tokens in a project always requires an additional form "authentication.
The Firebase Cloud Messaging versioned REST API requires that the user has a service account. If you create a service account for each of your service providers, you grant them complete access to your Firebase project. So they can't only send FCM messages, they can also access every other Firebase product: e.g. delete your database, read all your users, etc.
The legacy REST API for Firebase Cloud Messaging instead uses a Server Key to authorize its callers. If you share your FCM server key with other service providers, they can only send FCM messages with that key. But they can send whatever messages they want to whatever user.
You might want to consider setting up your own API endpoint on Cloud Functions for Firebase. That way you can determine yourself how to secure that API, and what you allow your service providers to send to what users of your app.
Assuming that the Firebase Device ID Key you're referring to is the FCM Registration token, then having the value alone won't enable others to send a message to it without the corresponding Server Key it is associated with.
For your use-case of allowing multiple senders to a single app, you could refer to the official documentation on Receiving messages from multiple senders. I believe my answer here could also be helpful.
I am running a Vapor server and I want to call FCM (Firebase Cloud Messaging) API in order to send notifications to my IOS app.
In Firebase console we are presented with two keys Server key and Legacy key.
Reading firebase cloud-messaging/send-message docs I have learnt that I have to send a HTTP POST request to https://fcm.googleapis.com/v1 with an access token .
Reading further under Authorize Send Requests I see there are different libraries (node.js, python) that enable one to generate an access token, but I think I will need to do that using REST since there is no library for SWIFT on server.
I can't find any library for swift to mint an OAUTH2.0 token using a service account and I was wondering if there is anyone who could show me how to mint the token using REST in Swift.
My website uses GCM (via OneSignal)
push notifications system.
I have to migrate push notification system to FCM (Firebase).
My goal is to migrate old tokens (and theirs relative tags/preferences) stored onto OneSignal into mine DB (on MongoDB) and send to that tokens my push notification via Firebase.
Reading Firebase's doc I don't understand if it is possible and how it is possible to reuse (or migrate/translate) old OneSignal tokens with Firebase.
Then:
Is it possible to reuse old OneSignal token with Firebase?
If n°1 is FALSE, how can I migrate old token to new token accessible with Firebase? Is there an API or JS method defined into Firebase SDK in order to translate old tokens.
I'm not familiar with how OneSignal works with GCM/FCM. What you should do is verify if the token used for OneSignal is either different or same to the actual registration token GCM works on.
The usual token format for GCM/FCM is something like this: 123456abcd:123456789abcdefghij. For a list of known characters for a GCM/FCM registration token, see here.
If it is the same, then you could simply use them as they are while proceeding to use FCM. Since FCM is still compatible with GCM tokens. However, there seems to be a really old version of GCM tokens that may be considered different from the latest format of GCM/FCM tokens (see here).
If the token is different, then unfortunately, I don't think there is a way for you to import those tokens to FCM (similar post, but for parse.com tokens). You could ask the OneSignal team if they might have the corresponding GCM tokens, but I can't say for sure.
Disclaimer: I'm no way associated or representing OneSignal in any manner.