I'm working on app, using Parse push notifications and Pubnub notification. I need GCM registration id for Pubnub, so when I register gcm and get the reg_id and subscribe for Pubnub channels, Pubnub starts working, but Parse stops working and when I use Parse's device token as Pubnub's reg_id then I don't receive Pubnub's notifications.
String reg_id =
ParseInstallation.getCurrentInstallation().getString("deviceToken");
With above reg_id I subscribe for pubnub notifications, I don't receive notifications on pubnub. I need both working together, how can I achieve this.
Related
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 tried sending notifications to GCM user using FCM console. But the notification delivered twice.
Is it possible to send notification to GCM registrations using FCM console.
Is there any way?
t-0: Someone has a server X that uses GCM to send notifications on certain events
t-1: I build my android app against server X and implement GCM. And it works great.
t-2: Firebase has a nice feature that lets you send notification from a console (similar to how Facebook's Parse used to work)
t-3: I change from GCM to FCM.
t-4: My android app can no longer receive notifications from server X
Now Firebase claims, and I quote
Updating these endpoints is not strictly required, as Google will
continue to support the existing GCM endpoints.
For the skeptics: I am working on two different git branches fcm and gcm. When I am on branch gcm notification works; but on fcm I cannot get notification from server X (but it works from the Console, yay!)
You'll have to continue using the old method you were using to send push notifications to GCM users and for the users who registers through FCM will only be able to receive push notifications through FCM or Firebase Notification console.
You can't send push notification to GCM registration tokens through FCM.
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
So I got the reg_id and can send notifications to my device. However the notifications are all with a default "Push notification message" vs the actual message.
The payload data I am sending is {'message':'this is a test'}.
In iOS APNS I would have done the same but the key being 'alert'.
Am I doing something wrong?