I'm using Sinch for App-to-App messaging with ManagedPush set to true which states that
NOTE: Using setSupportManagedPush(true) will register a token with Google Cloud Messaging using a Sender ID connected to Sinch, which will implicitly unregister your own token. You should not register any token with GCM if using Sinch push notifications.
Now beside push notifications from Sinch for Instant messaging, There are also other notifications i want to receive from my own server like general Ad etc for all users, I done some R&D but not able to figure out following
As Sinch registers GCM token itself so can i use the same token to send push notification from my own server?
If Answer for 1 is yes then how can i get Sinch registered token to send to my own server to receive notifications from my own server too along with one's sent via Sinch?
Or is there any way to get GCM token registered via Sinch from Google server?
If you already have your infrastrucutre to send push, I would use that instead of managed push. So instead of setSupportManagedPush(true) set setSupportPush(true) and then send the push to your server in onShouldSendPush event
Related
I am new with Firebase. I want to send push notifications to an android app from a spring application. At preset I dont have an android app. I want to test whether the firebase integration is correct or not, which means I want to make sure that the push notifications sent from the backend server are recieved correctly in firebase .
How do I ensure that firebase has recieved the push notifications sent from backend server?
Is it possible to test push notifications without an android app registered on firebase? If yes, how do I do that?
I am using Firebase Admin SDK. Do I need a separate server key other than the service account key for sending notifications?
You'll get a success (or fail) response when sending messages. This means that FCM has received your message and it will try to deliver it to the users.
FCM needs to target your app in order to send notification. If you don't set up FCM SDK in your app, it wont be able to do so.
You just need to generate an auth token. This guide should help you set it up.
In the project , I am generating device token for both IOS and Android using FCM. And push notifications . In my research, I found push notifications can be sent with https://fcm.googleapis.com/fcm/send
But is it possible to send push notification to IOS device, By using APNS api.sandbox.push.apple.com to the token generated with FCM ?
Apple docs Link
No. Api.sandbox.push.apple.com can only be used with Tokens generated by Apple. You need to fetch the Apple token in the client using didRegisterForRemoteNotificationsWithDeviceToken and send it to your server.
BTW, the Firebase SDK does exactly that and fetches this token in order to send iOS notifications. For each FireBase token they fetch the relevant Apple token from the device and use it when connecting to the Apple servers.
The problem is we have GCM integrated at the backend and when I try to add a new app to console it takes me to Firebase console when I click on google could messaging and when I send firebase device id to backend it is using GCM library to send notifications and gives mismatch sender id error. I know we have to implement FCM at the backend but is there any work around for sending notifications using GCM while using FCM device id from the backend?
I have two questions related to Android Push Notification System:
What is the working principle of this system? The client sends its own IP to the Google Cloud Messaging Service (for example when it switches its own IP)? So it a sort of pooling?.
How do you know that Google Cloud Messaging Service "looks into" the content of the notification message (created in the server and dispatched to the client)?
Answering the question about how GCM service contacts the client, the GCM client contacts GCM to create the connection. You are correct that device addresses change as the device disconnects and reconnects so GCM cannot initiate the connection from the server side.
This connection is maintained as much as possible and is not created for specific messages.
The registration id identifies the device and app and allows GCM to route the message to the device, if it is connected. If it is not connected, GCM needs to wait until the device reconnects.
What is the working principle of this system? The client sends its own
IP to the Google Cloud Messaging Service (for example when it switches
its own IP)? So it a sort of pooling?
I'm adding an image here describing how GCM works.
This is a step by step presentation. You need to get the push registration ID first when your application launches. So if you've a backend server to send some push notification in your application, you need to pass the registration ID to your backend server. So when you need to send a push notification, your backend server will send the push directly to GCM with the targeted registration ID. GCM manages to push the notification in your device when your device comes online.
So this is not any kind of pooling. The only thing GCM needs to know is the registration ID of your device when it comes online and tries to communicate with GCM. Once your device is registered, GCM sends the push notification using that registration ID.
How do you know that Google Cloud Messaging Service "looks into" the
content of the notification message (created in the server and
dispatched to the client)?
This question is not very clear to me. As far as I have understood, you wanted to know how GCM understands to whom it needs to send the push notification when the notification is coming from your backend server. If this is your question, then I think I have answered it already in the previous section of my answer.
GCM doesn't need to look into your notification content to know the destination of the push notification. As I said earlier, when your application launches, it requests for a push registration ID from GCM and when it receives an registration ID, you might have to pass the registration ID by calling a service of your backend server. The server then knows to whom it might send some notification.
So, when its time to send a notification to your client application, the backend server sends the notification to GCM with the registration ID you sent to your backend server earlier. GCM then handles sending the push notification to the client when the application comes online.
Hope that helps!
I am currently using GCM to push notifications to both an iOS and Android version of my app.
With Android, I am able to process any message I send from the server client side, and then decide what I want to do with it. For example, I can receive a request, check client-side if the user has push notifications enabled, and THEN send a push notification from the client side.
The question is: Are there any client side methods of sending push notifications for iOS, similar to Android?
To receive message, an iOS application needs to register with both Apple Push Notification service (APNs) and the GCM connection server. When a client app registers with GCM, it receives a registration token, which it must then send to the app server (the APNs device token is not sent to the server). The client app must store a boolean value indicating whether the registration token has been sent to the server.
You can follow this documentation on how to set up a client app on IOS.
Based on this SO question, It is very simple to implement APNs and GCM. You can follow this steps
When APNs (iOS Devices) and GCM (Android Device) registers for Push Notification on Apple and Google Server it generates a unique token for every device.
After that, you need to save that device token, with your device id or user id (unique id on your server for device) and the OS of device.
IOS device is sending this information on your server (backend) you can use this JSON format- {"token":"abcdedfgehik2bd3d3ff3sffssdff","os":"iOS","userid":34}
This is how it will work.
You request device token from APNs as usual.
You need to send that token to GCM service with provided API.
Then GCM sends back a another token.
Then send that token to app server.
App server can send notifications using that token.
Try also to check this for more information.