I have question about push notifications in Windows phone 8.
As i understand, there are three types of push notification:
Toast Notification.
Tile Notification.
Raw Notification.
So, in my opinion:
if the app is running, and opened in foreground:
Toast will be not shown, but i can handle it`s event and do something.
Tile will be updated automaticaly
Raw Notification must be handled by me. (Question one: can i do it without background task?)
if the app is running now, but suspended:
Toast will be shown as it came, without any event handling in my app, only "BindToToast()"
Tile Will be updated, without any event handling, only "BindToTile()"
Raw notification must be handled by background Task.
if the app is not open:
Toast will be shown automaticaly, if in previous launch "BindToToast()" was called.
Tile will update automaticaly, if in previous launch "BindToTile()" was called,
Question 2: what about raw notification? how to handle it here?
I think the situation is as follows:
Toast notification is shown only when the app is not running, but can be intercepted when it is
Tile notification always updates the tile regardless of application running
Raw notification can only be processed by the application when running.
Toast/raw notifications cannot normally be handled by a background task in Windows Phone 8.0. But there maybe a hack to get around this. See Windows Phone 8 notifications and background tasks and Windows Phone 8 Background Task with notifications
In Windows phone 8.1 it is quite possible to create a background task that is invoked when a notification is received, so the notification can be processed by the background task.
Related
I currently have a Windows Phone app that connects to a SignalR service to receive notification data. The service pushes data to the phone, which the app accepts, process etc and it’s all working as expected.
However, I would like the app to continue to receive the notification data when the app is suspended and no longer in the foreground, and display the notification data as a toast message.
From what I can see, the Background Task infrastructure offers no way to do this.
I have access to a Suspending and Resuming event (using Prism) so here I could Register/Unregister my background task.
For the trigger, the only one that comes close to being relevant is the TimeTrigger, but this only has a freshness time of 15 minutes, so assuming I am recreating the connection in the background task, I would end up opening and then instantly closing the connection every 15 minutes which isn't what I want to do.
I could have an “infinite await” that just hangs until a timeout, but this doesn't feel like the right way to go (and the resource usage would be terrible).
Is there a way around this to achieve what I want to do?
No, Windows Phone apps cannot keep a channel open like this. If the goal is only for toasts then you can do the computation on the server and push a toast notification.
Windows Store apps can do this with the ControlChannelTrigger class, but it is not supported on Windows Phone.
I'm developing a Windows Phone 8.0 Silverlight App based on the ChatterBox sample.
I can send a raw push notification to my app and a scheduled background task will start.
When the sample receives that push it will communicate with the Backend and simulate an incoming call.
In my case, I need to send a SIP REGISTER so that a SIP INVITE can arrive to the App and that will trigger all the VoipCoordinator mechanism.
The most practical way to do this is to bring my app to foreground, which will then send a SIP REGISTER.
Any hint?
Regards
I think you can push a Toast and when that Toast is pressed, it will activate the app.
I would like to launch an application using parameters provided from a push notification on Windows Phone 8.
The behaviour I wish to achieve is that as soon as the user receives the notification, the application will be launched with the parameters provided in the notification. I.e. seamlessly present the notification in a more user friendly way.
As far as I understood there are three push notification mechanisms. Toasts, Tiles and Raw.
None of them seems to be able to handle the wanted behaviour.
Toast: The message is shown even if the application hasn't been started. It does not start the application unless clicked on but seems to be closest to the target.
Tile: Message is shown if the application has been pinned. But they may be difficult to notice unless the tile is pinned fairly high on the start screen.
Raw: Works in more power states but requires the application to be running. This doesn't seem to be a match because I want the notification to be received when the application is not running. I couldn't find information about which application states where raw notifications are handled. I would prefer all.
Did I miss something in my research? If anyone has a hint of how to put an application in the foreground from a push notification (without user interaction) it would be greatly appreciated!
My first attempt was to trigger the application start using SMS but that seems to be a no go.
See my post Launch application automatically from an SMS on Windows Phone 8
You can not automatically launch an application on Windows Phone (and neither can you on iOS or Android). What you can do is provide a URI with the Push notification so the user is taken to a page with the needed information
you can not put an application in the foreground from background without user interaction.
I'm using Worklight 6.1 and sending push notifications to Windows Phone 8. It is working swell, except for the tile badge. It is not being cleared when I use the tile to launch the app. The notification that I'm sending is:
{"APNS":{ … },"GCM":{ … },"SMS":{ … },"MPNS":{"raw":{"payload":{}},"toast":{"text1":"Luggage Tracker","text2":"You have 3 available messages"},"tile":{"count":3}}}
The toast message pops up, and the tile gets the badge, but the badge doesn't clear when I launch the app, and the only way I can find to clear it is to have the server push another notification with: tile {count:0}
Is there any way for the app to clear the tile badge?
Update: the WL.Badge API is iOS-only. I have submitted an RFE to either enhance it or create specialized API for clearing the tile in Windows Phone 8 as well.
So the solution at this time, as I see it, is to create a Cordova plug-in to update the count... I found this plug-in. Perhaps you take from it when you need: https://github.com/sgrebnov/incubator-cordova-wp8/blob/master/plugins/www/plugins/LiveTiles/liveTilesExample.html
Use the WL.Badge.setNumber() API method.
Setting 0 should clear the badge from the tile.
WL.Badge.setNumber(0);
You can probably use this in the same logic that handles the received push (the one that shows the Toast pop up notification).
Worklight does not provide any mechanism to handle the badges other than methods to set or remove so you need to write one of your own.
My app is running on the foreground and the phone getting a incoming call. In the scenario, the phone is not raising any event to app like deactivated or closing. How do I identify my app not running ?
You app actually is still the current foreground app (so, kind of running, but audio/video is paused for obvious reasons).
You will get an Obscured event in the app, but you can't distinguish if this due to an incoming call, an incoming SMS, toast or reminder.
Here is a link to the MSDN documentation of the Obscured event you get. There is a corresponding Unobscured event you can also detect.