How to use channel uri in Windows Phone 8 App - windows-phone-8

How many channel should I use to send toast notifications, update of default tile and update of secondary tile?
Just now I use one channel on which i call BindToShellToast. I can send toast notifications and tile updates with this channel. Should I use a seperate channel for toast notifications? If yes, why?

It is not allowed by documentation to use both BindToShellToast and BindToShellTile() on one channel. As teste you can use a single channel for all push notifications you want to send.
If you dont need to access any resources (e.g. Images) in your push notification BindToShellToast() method to bind your channel. So use it if you need to send toast, tile (text only), raw notifications.
If you also want to use local resources (e.g. Images) e.g. for updating the background of a tile use the BindToShellTile() method to bind your channel.
If you also want to use non local resources (e.g. web images) e.g. for updating the background of a tile use the BindToShellTile(Collection) method to bind your channel.

Related

Windows Phone notifications force device uri update

I have a question about Push Notifications. As far as I know, when the App starts, it checks if exists a push channel and, if not, it creates a new channel. Also there is an event which starts when the uri is changed. And this Uri gets expired after 30 days.
But what I would like to know is: I want to send these notifications even if the user does not have the app running (let's suppose for a long time, more than 30 days).
Is posible to detect the Uri changed if the App is not running?
Could I force somehow device uri update?
EDIT:
I have read this information:
Each time your app starts, you should pass the URI from your push
channel to the cloud service that sends out the push notifications. It
is also recommended that you pass the device ID to your cloud service
so that the cloud service can track to which devices the URIs are
assigned. If a URI changes, then the cloud service can replace the old
URI for that device ID. Windows Phone does not provide a framework to
do this, since in most scenarios apps and cloud services already have
their own protocols that they use to communicate with each other.
From here
According to the text, my cloud service could send the new URI to the device, instead of updating the uri from the client? If so, do you know how could I do this?

Is it possible to programmatically connect to a chromecast route?

I'm writing a chromecast receiver application that will (hopefully) allow me to remotely put alert messages up on my TV to serve as reminders.
My plan was to have a dedicated wireless device on my home network that would constantly poll for new messages from a centralized server. When a new message was found, it would connect to a chromecast route, turning on the TV and displaying the new message.
But as far as I can tell, the only way to activate a chromecast route is by manually clicking the chromecast icon on my Chrome browser or wireless device.
Is there a way, programmatically, to activate the chromecast? Can it be done in the sender?
You can programmatically scan for cast devices and connect to them if needed. Steps are:
Get an instance of the MediaRouter singleton from the system: mMediaRouter
Build a selector:
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(
CastMediaControlIntent
.categoryForCast(YOUR_APP_ID)).build();
Add a callback to initiate scan:
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);
The onRouteAdded() and onRouteRemoved() of your callback (i.e. mMediaRouterCallback) will be called as routes are discovered or removed. You can maintain a list of routes in your app and keep them up to date by using these two callbacks.
You can select a route by calling mMediaRouter.selectRoute(aRouteInfo). Then the onRouteSelected() of your callback will be called and you can extract the cast device as usual and do as you please.
These said, remember that if you want to show a notification to users on TV your app should be running on the chromecast at the time you want to send the notification.

Windows phone 8 push notification how to use ChannelUpdatedUri to detect channel updates

I would like to know what is the clean & correct way to notify my WP8 app that the ChannelUri has changed?
I read that i need to handle this in the ChannelUpdatedUri method. But i have a few queries here. Doesn't this require my app to be running all the time?
Second query is suppose i use ChannelUpdatedUri to listen for changes to the Uri. If there is a change will the app be notified as soon as it launches? Or will it be notified at a later time?
The trouble is if the app is not notified on launch then there is a possibility that it may re-register for a new channel uri before ChannelUpdatedUri is invoked. Isnt it?
Please help!
You'll only get notified of a change in the ChannelUri when you have the listener attached and the app running.
The best approach is to always check for the current Uri and pass it to the server when the app starts. You could leave the listener attached for the lifetime of your app and get a new one if it's lost while the app is running but in reality it's far more likely that the channel will be dropped/disconnected when the phone isn't in use.
There is, of course, the scenario where a channelUri may expire when the app isn't in use but the utility of the app is primarily around sending notifications. Obviously you need the user to restart the app to get a new connection but you can't tell them to restart the app.
This is a generic problem: how do you tell someone that you can't talk to them?
The reality of this situation is that if you really need to tell someone to launch the app again you'll need another way to do it.
Unfortunately, it's not possible to get an updated channelUri from a background agent, but you could query your backend to see if you need one and then raise a toast to the user to prompt them to reopen the app. Or you could just update the tile from the agent when this happens.
Alternatively you'll need to send them the prompt in another way (e.g. email or SMS?) but this is reliant on you capturing and securely storing these details.
There is no perfect solution to this scenario other than creating an app that the user opens regularly regardless of whether there are notifications or not and simply having the notifications as an extra feature.

Displaying Tiles data with Time interval using Push Notifications in Metro Apps?

I have metro application in which I implemented Push notification concept for getting single message.If I get more than 1 notification,still my application tile is able to show only 1 notification(msg).Am not able to do how to display multiple notifications for time-specific.Means do I need to write any extra code for displaying multiple notifications on my tile.If so, where should I need do write either client-side or server-side?
Thank you.
There are several ways to look at updating, and depending on what your end goal is, you may end up implementing the code either on the client, or the server, or a little of both.
For the scenario you describe, you need to use Windows Notification Services to push the notification each time you want a new tile notification. Typically, this is done by having a service running in the cloud (a website, or a Windows Azure service, or similar), that calls Windows Notification Service and sends a tile update to the app when something of interest occurs.
If what you want is for multiple notifications to cycle on the tile, that's enabled by calling the enableNotificationQueue method on the TileUpdater class:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.tileupdater.enablenotificationqueue.aspx
Per the comment below, enableNotificationQueue works for any notification source. But if you want to pull information from a remote service, rather than using push, you can use scheduled polling as means of updating the tile using remote information, as described here:
http://msdn.microsoft.com/en-us/library/windows/apps/Hh761476.aspx
Combined with the call to enableNotificationQueue, it may also enable the scenario you're looking for.

When does a push notification channel change?

I have a metro application where am implementing push notification concept.Here I want to send channel URI to my server at the time my application installation,So in which event I need to get channel URI and in which event I need to send this URI to server.Actually, here I observed that the channel URI is varying only when we uninstall our application and re-installing.Otherwise it will be constant.Can anyone suggest me which events I need to use,here am using HTML5 & WinJS?
Thank you.
A new push notification channel URI isn't always created when the channel API is called. The CreatePushNotificationChannelForApplicationAsync method will return a cached local copy of the channel URI for a period of time (currently 24 hours).
The how-to article on MSDN provides guidance about channel management summarized here:
Whenever the app is run, request a new channel.
If the new channel URI is different from the old channel URI:
Replace the channel URI on the service with the new channel URI.
Once your service has the channel, store the new channel URI for future comparisons.