How to send notification from handheld to wear to open Activity on wear device - android-notifications

I'm wondering if it is possible to send notification from handheld (android phone) to wear device to open Activity on wear device? What I want to do is as following.
So far, I checked the following documents, but it's different from what I want to do.
Adding Wearable Features to Notifications
What is described here is sending notification from phone to wear, then open activity on the phone (I want to open activity on the wear)
Create Custom Notifications
What is described here is sending notification from wear to wear, then open activity on the wear (I want to send notification from phone to wear)
Any ideas?

The pattern to use for this is:
Create a DataItem on the mobile. It will be synced to the connected wearable automatically.
On the wearable, implement a WearableListenerService and listen for onDataChanged events.
When you receive a DataItem, create a notification (with the data sent in the DataItem) and send it locally (i.e. on the wearable). Use setContentIntent() on the notification to specify a pending intent that will launch your wearable activity.
Don't forget to also provide an intent that is fired when the user dismisses the notification on the wearable, so that the DataItem can be removed. Otherwise, you will not receive any update events.
I've created a sample project that shows all of this in action.
Check out this question if the onDataChanged method is not getting called.

I think in most cases it would be better to include your app activity inside the notification.
For example, instead of the "Open" button in your notification, you could use setDisplayIntent(notificationPendingIntent) to display an activity as part of the notification as described here:
http://developer.android.com/training/wearables/apps/layouts.html
This gives you a best of both worlds situation between having an app and a notification.

Related

Windows Phone push notification multiple Devices in one request

i'm trying to implement push notification for our Windows Phone apps. We have about 40, 50 games on Mobile Phones, each game we have about ~400.000 users on their device.
I read some tutorial about push notification for Windows Phone such as this (http://joashpereira.com/blog/2015/03/18/php-script-to-send-android-ios-and-windwos-phone-push-notification/), but there's a problem is that we can only send push notification to one device per request. If i use this method, our program will process very very slow.
It's not look like Android or IOS, where i can send notification to ~1000 devices per request. That's pretty easier.
Anyone know how i can deal with this problem? Pls Help, thanks.
[Answer to a comment in the question]
The send method of the NotificationHub returns a NotificationOutcome object. This object contains several informations. Also a TrackingId which is a unique identifier which has been generated by the Notification Hub. But at the moment you have no possibility (as far as I know) to get more informations.
You can use the TrackingId to contact the azure-support, when you have problems or questions.
The problem is, that azure don't send the notifications directly to the devices. Azure just sends it to the device specific notification server (APNS, GCM, MPNS), and this server decide about the time to send the notificaiton
Look at this page at the end (section 'Debug failed notifications/ Review notification outcome' or 'Review telemetry') for more informations.

Can I find out if an Android iOS or Windows Phone 8 push notification was delivered?

Can you interrogate the Apple (APNS), Google (GCM) or Windows Phone push notification servers after the fact to find if a notification was delivered?
I know that when a server initially sends the push notification there is a response to say whether the message was processed (but this doesn't mean delivered) or rejected by the notification server. But is there any way to subsequently find out via Android, iOS or Windows Phone 8 if the message was delivered?
Ideally I'd like to achieve this just by interrogating the vendor's push notification server, worst case I'm assuming I'd have to put something in my app to register that a given notification arrived and somehow transmit this success status back to my server.
APNS, GCM and MPNs don't offer this functionality.
You'll have to support it yourself, by sending an acknowledgment from the app to your server whenever a notification reaches your app.
For GCM you can view statistics of deliveries, but nothing for individual deliveries :
Viewing Statistics
To view statistics and any error messages for your GCM applications:
Go to the Developer Console.
Login with your developer account.
You will see a page that has a list of all of your apps.
Click on the "statistics" link next to the app for which you want to view GCM
stats.
Now you are on the statistics page.
Go to the drop-down menu and select the GCM metric you want to view.
Note: Stats on the Google API Console are not enabled for GCM. You
must use the Developer Console.

Alert me Windows Phone Push Notifications In Azure Mobile Service

Basically my understanding of push notifications is that they can change tiles and display a message to the user when the app is closed.
What I would like to know is if its the right way to go as the main control method in a turn based mobile game? For example the specific situation im wondering about is if the user has the application open and they make their move which gets sent off to my service could the application then sit and listen for the push notification reply and update the ui/continue with the users turn? obviously if the user moved away it should still do the sort of notification mentioned first that updates tiles/ displays a message but if the apps open it should just use a value in the notification and the user should never know it was a notification, just see the other players move and continue with theirs?
thank you
John Harris
Toast notifications are ignored if your app is already running, unless you register for the ShellToastNotificationReceived event. Your app can then decide how it wants to respond to the toast notification.
As you can see from this quote, if the app is open, it can choose to recieve toast notifications and decide how to handle them.
When the app is running you can also receive raw notifications, which can contain more data than toast notifications.

Worklight: two users Same device Push subscription

I have a scenario presented by business team that: one person has device and he subscribed for Push Notification, later on his wife use the same device and subscribe for Push on her account.
Now in this case:
will Push go two times to the same device?
Or, the previous device subscription will be overridden
Plus, my App saves all Push notification messages on user's devices (as transaction history) , shouldn't be the problem!
To handle this scenario, what could be the possible options?
I am using Worklight Consumer 5.0.5
Thanks
Once you subscribe with different user on a same device the old subscription will be deleted. This is done for security reasons, e.g. in case you sell/loose/give your device new user should not get notifications of old one.

sending ios push message without user action

I want to collect device attributes and send them to the mdm server using push notification.
Steps involved are:
create a configuration profile with mdm payload
get device token
use apple push notification service to send a notification to the device.
get back device attributes
do same with multiple devices which the company manages
Questions:
Will the user always need to act on a message or I can send a message onto the device without user action and get the work done?
Do I need an app on the device to send back the token?
It sounds like you're trying to use push notifications to poll iOS devices and return information.
Push notifications do not provide a mechanism to execute code on a device without user interaction. You would have to have an application loaded on the device, and the user would have to click through from the notification to your app.
In iOS, applications generally don't run unless the user is actively interacting with them. There are a few exceptions (e.g. background audio.)
You do need to have an app running to get the device token. You call registerForRemoteNotificationTypes. See APNs docs for more information.
Edited to add more information:
Looks like the MDM protocol uses push notifications to do just what you describe. However, there's nothing about it in Apple's "Local and Push Notification Programming Guide" (linked above).
Apparently Apple keeps tight control over the MDM documentation (see here and here).
However, I did find this paper from blackhat describing how the system works.
My earlier point about not executing arbitrary code on a device without user interaction still applies. There's a finite set of commands that can be executed (see Appendix A).
I came across this question when searching for iOS push notification access payload without user interaction - Just want to add that, in iOS 7 and above, it is possible to send silent push notifications to app, and app can process them without user interaction.
However, I've also found some discussions saying that the silent push notifications are not delivered reliably, in this SO post. That's why I'm still looking for alternate ways to retrieve payloads of the normal remote push notifications. Doesn't look like there's a way.

Resources