I am trying to set up FCM functionalities into my app. At the moment, I would like to display a button such that when the user presses the button an upstream message is generated which is sent to Google's CCS. It is my understanding that this upstream message will be turned into an XMPP stanza by the Google CCS. Then, it will be delivered to the phone that has the id I set to when creating the upstream message. After reading the documentation on FCM from google, I see that it is very simple to create an upstream message:
FirebaseMessaging fm = FirebaseMessaging.getInstance();
fm.send(new RemoteMessage.Builder(SENDER_ID + "@gcm.googleapis.com")
.setMessageId(Integer.toString(msgId.incrementAndGet()))
.addData("my_message", "Hello World")
.addData("my_action","SAY_HELLO")
.addData()//somewhere in here must be a way to set the senderId of the phone
// i am trying to send the message to ???
.build());
Now by looking at the code above, i see in no way XMPP being used to create this upstream message. No XMPP stanza creation. My question deals with where does this XMPP stanza be delivered to? Once it leaves Google's CCS. I see a method on the class that extends FirebaseMessagingService called onMessageReceived. It is my understanding that in this method is where the XMPP stanza will be delievered. Or, will it be delivered on the Smack library connection I intend to set up which will have a PacketListener. According to the example by "Gronkking Android", Google's CCS XMPP stanzas will be delivered here on this packetlistener. I do intend to follow this example to receive these coming stanzas and generate the required ack messages.
If anyone has any thoughts or ideas it would be great to hear your comments
Thank you
FCM cloud service is good for PUSH notifications downstream from a corporation system, or a bank system, etc. Otherwise, to do the job of upstream message, you need your own XMPP application server (usually on public IP), I don't see any way around it. The FCM cloud service will just forward all the messages received to it without even reading them; it will be the application server duty, to route all the messages to the correct mobile device, always by recalling the FCM cloud service. I guess it would be easier without FCM service in the middle, just using your own XMPP server at some public IP, and the mobile device app should work like an XMPP client.
Device to device messaging is not supported by FCM. Upstream messages are designed to go from your mobile device through CCS to your XMPP app server. Once your XMPP app server receives the message it can decide to send a downstream message through CCS to a mobile device. The XMPP communication with stanzas is done between CCS and your XMPP app server.