1

I want to send message from one mobile to another mobile(Push Notification). Firebase has a push notification service, but it's not directly between mobile to mobile.

It's either mobile to desktop(Upstream), or desktop to mobile(downstream).

Basically the app is supposed to send alert from one mobile to another.

I am beginner, would really appreciate if there's already a function for this.

Arif Raza
  • 21
  • 2
  • Apps on different devices cannot know the device Token of other devices . The least you can do from a device to send a Message to a Topic . So all the subscriber of this topic will receive the notification .. – ADM May 28 '19 at 11:40
  • There is no secure way to send push notifications from one device directly to another with just Firebase Cloud Messaging, since you need to know the FCM server key to *send* a message; and knowing the server key in a client device means that any client can send any message to all of your app's users. Some other services offer such a service, since they provide another way to secure the message sending, but Firebase Cloud Messaging does not. So if you just want to use FCM, you will need a server. See https://stackoverflow.com/a/39279716 and https://stackoverflow.com/a/37993724. – Frank van Puffelen May 28 '19 at 13:55

2 Answers2

0

It is not possible at least not in Sweden because the mobile operators are doing som funky routings with the ip address. Because of this it is only possible to create an outgoing connection from a mobile phone. Even if you have the mobile ip address you cant lock on and get an in going connection.

This is why there are services like Firebase, Signal and others that offer the flexibility to solve this problem

Of course some operators offers static ip adress for an extra fee, that would make it possible to run anything incoming, but users in general does not subscriber to this since they have no use for it

Look forward to if someone can prove me wrong..

Erik
  • 5,039
  • 10
  • 63
  • 119
0

I have done this with the help of a web configuration.

You will need a Web database table to save the FCM Token and username for each device.

Username can be any unique thing you can get from any registration process you want or you can hard code that as well for testing purpose but FCM Token Id must be auto Generated you can find the code how to get it form web.

Every Device FCM Token ID is attached with the username and must be unique which will be used to distinguish between all the devices in web.

Now the Process will be--

sender mobile -> Server Having all the FCM token id (and code to send notification) -> Receiver Mobile

From sender device you call the server, sending it the message and the receiver's username.

Now at server side it will search its table and find the particular FCM Token id for the specific username you have sent.

Now it will send the given message to the device of that specific token Id.

Hope this will help you!