Push notifications between ANDROID devices - android

I am trying to figure out how to push a received notifications from one android device to another one. Example: someone sends you a message on your android phone. You receive a notification on your watch that this happened. Any suggestions?

If I understood correctly what you want is to receive a notification on the android watch when you receive a notification on the phone is that right?
Well this happens automatically so if you don't want to add anything extra or custom to a notification you don't have to do anything.
If you want to produce custom notification for wearable with specific actions, icons or other thing you need to follow the android guidelines at https://developer.android.com/training/wearables/notifications/creating.html
You might need to intercept the notification you receive on the phone and handle it like this and then send it again to both phone and watch.

This is solely for communication between Android devices that each have Google Play Services installed and valid registration IDs:
You will need a bidirectional implementation of GCM, one that allows devices to both receive and send messages to the server. The HTTP GCM server setup will only allow downstream communication (server -> device). For your needs you can use the XMPP implementation of GCM.

Related

How to send FCM notification to single device from multiple devices

If application install in 10 devices then how can FCM notification will send to one of the device.
The easiest way to do that is to send a notification with a topic.
Subscribe the one device to a topic like that:
FirebaseMessaging.getInstance().subscribeToTopic("weather");
More information here.

Handling notifications in android

I would like to know what is best practice when operating with push notifications in particular GCM notifications. Where should I ignore the notification from the server side. That is to say the server only send notifications to active users or the client side where the server sends out notifications but the app ignores them based on whether the activity is open or closed.
It's always better to decide at the server side which devices have active users, and only send notifications to them.
The reasons:
You don't want to run any code in the client side if you are not going to do anything with the incoming GCM message, since that would just be a waste or battery life.
It's better to reduce the number of messages your server sends to GCM server, since this way, the devices that should recieve and display the notifications will recieve them faster.

Push notification don't recieved on some device

I am implemented push notification in APP using Google cloud message
http://developer.android.com/google/gcm/client.html
but I faced problem.
On some devices we receive push on another not. I testing two the same devices on one working on another no. But after "Back up and reset" settings on doesn't working device he start receive Push messages. Does anybody have this problem? Or there are some restrictions on GCM (maybe with accounts on devices or GCM conflict with some program).

Handling Push Notification scenarios on iOS and Android

I want to implement Push Notification for an App (both iOS and Android) and need clarifications on the following scenarios.
I understand how the Push Notification works in general and the limitations. I did read the docs but that just got me confused and didnt answer all my questions.
How are the following scenarios handled in iOS and Android:
When the device is turned off
When the device is not connected to 3G or Wifi networks
When the device has crashed and need restart
When the App is in foreground
When the App is in the background
When user is currently using the App
When my app is closed (not opened / launched)
When a push notification is user specific and both users share the same device and app. Example: If a husband and wife share same device and use a bank App with Push notification.
Can you send User specific notification if device is shared by multiple users?
When user has installed App on multiple devices
Can you send a notification to all devices registered by a user at once?
Do you store the device type (iOS or Android) with the registrationID in the User table or is there a way to differentiate the type of device by inspecting the token or registrationID?
Can you cancel a previously sent notification which is not read yet and send a new one?
Is it still true that Android Push Notifications does not work on Kindle Fire and will need to implement Amazon Device Messaging
Anything else that I need to think of or plan? I am aware of handling un-registering and feedback service
I would answer some of your questions, specific to android thought. Don't know about iPhone, If its of similar kind or not.
The device receives notification from Google Cloud server as and
when the notification is triggered by the server and it doesn't have
any relation with application state (Running, Closed, Background or
foreground).
If the notification is sent to a device when its not connected to
the internet ( switched off or not connected to the net) , it gets
notification only when it connects to the network. However, if the device
is crashed and restarted after the notification is received, you
won't get the notification again.
Is it user specific?
It depends on the individual servers implementation.
Do we store device type?
Yes we can.
Can we differentiate the IDs of iPhone and android?
Yes, android Device IDs are longer in length than iPhone's.
Can we cancel an already sent notification?
No, it is a one way communication channel as far as I know.
When the device is turned off:
Answer:
IOS/Android Server (Not your Server) will handled when to send the Push Notification. It checks that device is reachable or not. We can define that how many times IOS/Android Server should try to send Push Notification.
When the device is not connected to 3G or Wifi networks
Answer:
Nothing related to 2G/3G/Wi-Fi. Device should be connected to Internet via any network.
When the device has crashed and need restart
Answer:
IOS/Android Server checks that device is reachable or not.
When the App is in foreground
Answer:
Nothing related to app in foreground.
When the App is in the background
Answer:
Nothing related to app in background.
When user is currently using the App
Answer:
Nothing related to app being used currently.
When my app is closed (not opened / launched)
Answer:
Nothing related to app is closed.
When a push notification is user specific and both users share the same device and app. Example: If a husband and wife share same device and use a bank App with Push notification.
Answer:
It depends on how you have implemented on YOUR Server. You will be managing Device Id for each user. So it's upto your implementation logic to send to same device for multiple users.
Can you send User specific notification if device is shared by multiple users?
Answer:
It depends on how you have implemented on YOUR Server. You will be managing Device Id for each user. So it's upto your implementation logic.
When user has installed App on multiple devices
Answer:
It depends on how you have implemented on YOUR Server.
Can you send a notification to all devices registered by a user at once?
Answer:
Yes again as per your implementation logic.
Do you store the device type (iOS or Android) with the registrationID in the User table or is there a way to differentiate the type of device by inspecting the token or registrationID?
Answer:
Yes you need to store the device type, to identify to which Server (IOS/Android), you need to send request for Push Notification.
Can you cancel a previously sent notification which is not read yet and send a new one?
Answer:
No you cannot cancel the request.
Is it still true that Android Push Notifications does not work on Kindle Fire and will need to implement Amazon Device Messaging
Answer:
Need to google it around.
Anything else that I need to think of or plan? I am aware of handling un-registering and feedback service
Answer:
Need to google it around.

May I send notification from Android to iOS or vice versa?

I need to develop an application which sends notification to other device based on current action.
The device on which I need to send notification that might be iOS device or Android device too I am not sure which device he/she is using.
I know about remote notification and push notification in Android and iOS respectively which work for either for Android or iOS only.
But I dont know about the notifications which can work between these two different OS, so If anybody can help me, it would be a great help.
Your query is sounds different and tricky,
There are two alternative to achieve this task.
First thing you can use Web-Service and sending and receiving
request & response as per that platform code. like request parmas should be fix and base on that you have to read that response.So,it could be easy task.
Next way is long and complex.Like create background Bluetooth connection sending your message to other device either it could be message or file.If you are sending a file then you have to read via file stream.
But second trick have limitation and that is area both device should be in Bluetooth range.
So, i would like to prefer first way to achieve your task.
I think you can create a web service that will use GCM (for Android) and Push Notifications for (iOS). This is the standard way the notifications are created, but you can do other interesting stuffs with it, something like, you register your device by sending the notification tokne, OS, and a name or other details that your app stores or display and in response you get similar users/data which you can notify. When you want to notify a device/user/etc, you just send a request to the server with the name/user (something unique) and the server will get the token from the database, the OS, and will decide what to use GCM or push notificatiom, and the device will be notified.
Also there are a lots of tutorials for implementing GCM notifications and push notification, both on server side and mobile side
"Next way is long and complex.Like create background Bluetooth connection sending your message to other device either it could be message or file.If you are sending a file then you have to read via file stream."
But still do you think it's possible to achieve ?
In some case it can be usefull, let me explain. For people (like me) who have a 5" smartphones or more (ascend mate 6.3"), they could be tempt to let their huge phone in their bag, unless you have giant pockets. So let say you also have an ipod touch in your pocket and the huge smartphone in your bag, your ipod touch can be able to inform you if you have received any mails, text, phone calls or any notification you can imagine.
Well I hope understand what I'm thinking of.

Categories

Resources