Sending push notification from different servers - google-cloud-messaging

We have an app. App can register to different servers: Server1 and Server2.
Now, Server1 and Server2 wants to send push notifications to an app independently. How to solve it using GCM?
I don't know how to implement in the sense of SenderID, registration token. Can an app has one SenderID for every app server? Should I has a one SenderID and generates different registration token for every app server?

Now, Server1 and Server2 wants to send push notifications to an app independently. How to solve it using GCM?
Have each server create their own FCM project (it seems you're a new user so it would be advisable to proceed using FCM now), each would have it's own SenderId, which the client would be generating a token for each (see my answer here or here).
Then have the servers send to their corresponding tokens as needed.
Can an app has one SenderID for every app server?
Yup. See what I mentioned above.
Should I has a one SenderID and generates different registration token for every app server?
Yup. It's the correct approach, see what mentioned above.

Related

Can a server configured with one Firebase project send notifications to an individual user of an app in a different project?

I am using Firebase with React Native. There are two different projects with one Android app under each project.
My backend server is configured to receive/store the FCM token of every individual app user. Right now, the same backend server caters to both apps. The FCM json config file for the backend server is based on one of the aforementioned two projects.
Can the backend send notifications to an user of either of the two apps, as long as it has their FCM token?
You can do this so long as it comes from the respective apps FCM credentials, this prevents abuse and FCM hijacking. this does not mean that you need cloud functions on multiple projects as you can manually instantiate new admin-sdk modules to connect and send FCM messages as needed.
Initiate Multiple Apps: https://firebase.google.com/docs/admin/setup#initialize-multiple-apps
A side note to consider: You may also be interested in registering the FCM if your app has multiple projects as only the default app is registered with normal behaviour.
FirebaseMessaging.getInstance(firebaseApp) for secondary app supposed to be public but it's private?

One XMPP connection for more than one GCM/FCM app

I have a bunch of FCM projects and I'd like to use the same XMPP connection to send messages for all those projects. The FCM docs say that each connection needs to authenticate with the app id and server key, meaning I can use one XMPP connection for one project only. Is there any way around this?
I'm not sure what the question is here. Just use the corresponding Sender ID and Server Key from your Firebase Project. However, do note of the connection limitation mentioned in the docs you linked:
For each sender ID, FCM allows 1000 connections in parallel.
I don't really see any issue here, so long as you're using the same Firebase Project for FCM on all of your apps, you're good to go.
Unfortunately, if you have multiple projects, the only workaround I can only see that you can do is for you to use only a single project for your FCM processes.

Google Cloud Messaging token

I'd like to know if each time my application runs I need to get the token and pass it to the server, or if it's only necessary once to register the application. Thanks a lot.
You need a token to register the GCM(push notification) to the Google Server. Then this token is passed and used in the server to send subsequent notification. This token should be persisted by the server so that it can be used to make API calls to the Google server. With this approach, your server and the Android device do not need to create a persistent connection and the responsibility of queuing and relaying messages is all handled by Google's servers.
For more information visit the Registering Client Apps and also check this documentation.

Firebase certificate authentication

I have no interest in authenticating my clients as they are.
I do, however, want to make sure that anyone reaching my FireBase is authorized. Namely, that it's only via my Android app.
Could it be done somehow? I couldn't find any option or alternative in FireBase documentation.
The best approach I see is to have my app signed by a certificate, and aithorize itself using it.
To authenticate your app, use FCM (but regretably, it requires a server code):
Create an anonymous firebase account.
send an FCM message to your server, with the firebase account uid.
the server will create a node such as /uids/$uid/enabled.
have a rule to require it, e.g.:
".read" : "root.child('uids').child(auth.uid).child('enabled').val() == true"
The reason for the FCM message, is that in order to send such a message, the app should be "registered", which means the developer's signing certificate for the app is known. anyone attempting to send such an FCM message and not through your app will fail - even if someone re-sign (and probably modify) your app.
The drawback is, of course, you need your server to receive FCMs - which is very easy on the device, but harder on the server side.

Cannot register in sample BlackBerry push application

I am developing a BlackBerry application in which I need to use PUSH API. I already have registered with RIM and they have sent me the credentials for evaluation service. In my BlackBerry device, I installed sample push API application just to test that the push messaging works. After setting the content provider URL which is publicly accessible, I entered all the details for the sample application to register the it for receiving notification messages. When trying to register it asks for username and password but I don't know what they are for. In the email received from RIM, there are passwords for server application and content provider admin portal applications but not for the push client.
When I added an arbitrary username and password it fails with the message that java.lang.Exception Registration with Push API failed, caused by port is unavailable. But when I unregister it successfully unregisters the user with the given arbitrary username and password. By the I use the port given in the RIM's email.
I have no idea why this happens and I appreciate immediate response from you. Thank you.
The first thing to point out is that the RIM sample push application is ridiculously overcomplicated. The username and password you are referring to are used to authenticate against the sample push initiator web application which runs on your tomcat server. It doesn't matter what you put in there, they are not used for authentication. I can only assume they were added to show you that you can send a username and password to a web based service.
The only things you need in your BlackBerry app to register for the push service are:
Push Application ID (e.g. 2672-c870l6c924r1i298O4o33cc5391y0e75134)
Push Port (e.g. 31940)
BlackBerry Push Server URL (e.g. http://pushapi.eval.blackberry.com)
The port is unavailable message you're receiving is probably because the device you're using has not been provisioned for BlackBerry Internet Services (BIS). Make sure it has a SIM with an active BlackBerry data plan.