Push notification clarification
-
Thursday, April 22, 2010 2:32 AM
Following the instructions at: http://www.sgtconker.com/2010/03/article-windows-phone-7-push-notifications/ I'm able to get Toast notifications pushed to my emulator. I had a few questions regarding the specifics:
- What is the "channel name" used in channel = HttpNotificationChannel.Find(channelName); Is this a unique name for your App or the specific user?
- The URI created by the app appears to change every time you deploy. Is the idea to send the URI back to the server you control as a unique URL for this user (and possibly each instance)? I read on this forum that you cannot send a single message to multiple users.
- Does a Toast notification notify when you are outside of your app (it does if i go to the home screen and IE on the emulator)? Do you have to run the App first to register the notifications? Does it work if you haven't run your program yet?
Thanks!
Answers
-
Sunday, May 02, 2010 6:38 PM
Ok, I found the issue: RTFRN. In the release notes:
- All Applications using Push Notification(existing or new ones ) need to add entry for publisher. Perform the following steps since the default entry for Publisher is empty:
- Open wmappmanifest.xml, under Properties in the Solution Explorer
- Edit Publisher="" to Publisher="<something>"
- Redploy
I edited the wmappmanifest and put a string in the Publisher attribute of the app element.
I redeployed and it worked.
- Proposed As Answer by Bit Shifter Sunday, May 02, 2010 6:38 PM
- Marked As Answer by Dan ReaganMicrosoft Employee, Moderator Thursday, May 13, 2010 6:05 PM
All Replies
-
Thursday, April 22, 2010 3:00 AM
Hi Acidd22,
I'm not sure on the purpose of the channel name, since the channel URI uniquely identifies the app and the device. Perhaps in the future the live service would use this to return your original URI based on identifying your app (deployment?) and channel name - if you're saying it's not doing this already?
Perhaps not if based on "an app deployment identifier" which is done each time you start up your emulator, rather than an "app idenfitier".
On a real device I expect this URI can be sent to your web service once and used repeatedly to push notifications to the device that the URI was given to by live.
I'm not sure if your code is requesting a new uri each time you run your app. If you are I expect this may be the reason you are getting a uri per deployment.
I believe the premise of toast notifications is that they can popup on the users device regardless of what they have active on the phone at the time.To register the notification I would imagine your app needs to run, as it will be your app which first requests the push uri from the live service. I don't see how this could work without first running your program on a real device.
I have not tested it on the emulator to see if each execution of the emulator is considered to be a new device. IE can you reuse the URI between emulator sessions and receive the toast? You could test this fairly readily with the code you have running I'd imagine.
If you do have to get a new uri each time you run the emulator I suppose that is just a temporary limitation of the emulator. I would be inclined to put the uri request code behind some user initiated action which would cater for the emulator and real device scenarios anyway I suspect.
-
Thursday, April 22, 2010 3:15 AM
There does not seem to be any description anywhere I can find of what the channel name is supposed to be. From what I can gather, it is a name used within your app to identify that particular notification. Kind of like a named mutex in Windows. The name means nothing except for searching if it exists.
If you use the same channel name across different app sessions (without restarting the emulator), the first session will create the channel and subsequent sessions will return the channel created by the first session. The documentation says to get the URI each time the app is started because it may change at any time. Your app will send this URI to the server each time it starts.
You will have to run the app at least once to create and bind the notification channels. For toast notifications, the toast will only show if your app is not in the foreground. If your app is in the foreground, you will receive the ShellNotificationReceived event.
-
Thursday, April 22, 2010 5:12 AMNote that I cannot even get the channel to open, so you're having more luck than me.
-
Thursday, April 22, 2010 7:33 AM
Hi all,
The code from the Url I had tested, but I can not open the channel either, MAYBE there is because the XML code I han't add to the project, but I have no idea why need to add it and where to add, really confuse by how the channel work with the XML code there, Is there anyone give me some idea for that, Thanks in advance!
-
Thursday, April 22, 2010 7:39 AMOnce I got the channel opened and a URI returned, I used Sgt. Conker's WP7 Push Tool to send the push notification. He describes it well in that article, and provides the source so you can study that.
-
Saturday, May 01, 2010 10:20 PM
How did you all manage to get a channel URI with the April Refresh CTP? Regardless of what I'm trying: The first open fails, the second succeeds, the third excepts with NotificationChannelExistsException. The channel_ChannelUriUpdated never fires. Channel.channelUri cannot be read "expression cannot be evaluated".
neil -
Saturday, May 01, 2010 10:59 PMI haven't tried it yet with the latest CTP. Will do when I'm back in the office.
-
Sunday, May 02, 2010 8:03 AM
I also have not been able to get the Push Notifications working with the April Refresh CTP. After calling Open on the HttpNotificationChannel
, the ExceptionOccurred event fires and the args give this.
Microsoft.Phone.Notification.NotificationChannelOpenException: NotificationChannelOpenException
The _HResult is -2146233088 (0x80131500)
The innerException is null. The message is simply: "NotificationChannelOpenException"
Has anyone had success after the April refresh? -
Sunday, May 02, 2010 1:50 PM
I also have not been able to get the Push Notifications working with the April Refresh CTP. After calling Open on the HttpNotificationChannel
, the ExceptionOccurred event fires and the args give this.
Microsoft.Phone.Notification.NotificationChannelOpenException: NotificationChannelOpenException
The _HResult is -2146233088 (0x80131500)
The innerException is null. The message is simply: "NotificationChannelOpenException"
Has anyone had success after the April refresh?
Take a look here: http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/37daccba-9d64-4850-9079-b08bc3492beeBye
-
Sunday, May 02, 2010 3:35 PM
I currently experience the exact same behavior as Bit.Shifter and Neil with the April refresh. Code which seemed to work before now refuses to open a channel and/or invoke the URL changed callback afterward. (Only talking about the phone portion, not about the "sender" part ... it's already the phone part which seems to fail.)
-Ingo
-
Sunday, May 02, 2010 5:55 PM
Mighell,
I had read and tried the suggestions of this thread prior to writing my post. Have you successfully got this feature to work with the April Refresh in place?
I used netmon to try to get some clues and found that for me (at about 148 seconds after the power-on of the emulator) there is a GET request to push.live.net /Bootstrap/v01
This bootstrap request gets a 200 back from the push server and the payload contains this:
HTTPPayloadLine: Dip:tcps://65.55.74.53:443/
After I saw this http traffic in netmon, I use my phone app (click da button) call the functions:
channel = new HttpNotificationChannel(channelName); channel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(channel_ChannelUriUpdated); channel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(channel_HttpNotificationReceived); channel.ExceptionOccurred += new EventHandler<NotificationChannelExceptionEventArgs>(channel_ExceptionOccurred); try { channel.Open(); channel.BindToShellNotification(); } catch (Exception err) { channel = null; isConnected = false; txtStatus.Text = "Status: Failed"; }Very quickly after calling Open(), the exception event delegate then fires
void channel_ExceptionOccurred(object sender, NotificationChannelExceptionEventArgs e)
{
Debug.WriteLine(e.Exception.ToString());
}
I posted the values from the exception in my first post above.
I see the traffic in netmon to 65.55.74.53:443, unfortunately the traffic is encrypted… I can’t see any further clues…
Ingo and I have no luck, anyone else get this to work?
-
Sunday, May 02, 2010 6:38 PM
Ok, I found the issue: RTFRN. In the release notes:
- All Applications using Push Notification(existing or new ones ) need to add entry for publisher. Perform the following steps since the default entry for Publisher is empty:
- Open wmappmanifest.xml, under Properties in the Solution Explorer
- Edit Publisher="" to Publisher="<something>"
- Redploy
I edited the wmappmanifest and put a string in the Publisher attribute of the app element.
I redeployed and it worked.
- Proposed As Answer by Bit Shifter Sunday, May 02, 2010 6:38 PM
- Marked As Answer by Dan ReaganMicrosoft Employee, Moderator Thursday, May 13, 2010 6:05 PM
-
Sunday, May 02, 2010 7:40 PM
Wow, what a cool find! That's it. I set the Publisher attribute to "MeAndMrsJones" and it worked :)
Many thanks for sharing.
Regards
neil -
Sunday, May 02, 2010 9:24 PM
Aahhh... very nice. Thanks for sharing! I don't know how long I've been looking for this but I must have overlooked that part in the RN.
-Ingo
-
Saturday, August 28, 2010 4:05 AM
Thanks for this information. I'm using the latest version of the WP7 tools. I'm now getting the same URL every time I get the channel URI. Do you know if this URL is unique to my phone (or emulator?) or the channel name? I want to know if i push out an notification, does it go to everyone using this channel name, does every user get a different URL, or do i need to create a unique channel name for each user (This would seem hard to track).
Otherwise, i'm able to push notifications very easily!
-
Saturday, August 28, 2010 12:07 PMThe URL is unique for that app on that device. It may change occasionally, but you may also get the same URL for that app on that device.
-
Saturday, August 28, 2010 12:21 PM
The URL is unique for that app on that device. It may change occasionally, but you may also get the same URL for that app on that device.
Thanks. I want to make sure i'm not sending a message to everyone using that channel or publisher name!So, if the URL may change, it is a standard practice to get the URL from the app every time it launches and send it back to the push server to make sure its always up to date? How would you know to get rid of old URLs? I noticed you get a response message so you know if it was received and actually sent to the application, or if it was suppressed for some reason.
-
Saturday, August 28, 2010 11:45 PM
When your app starts, you should always get the URL for the push notification channel. Most apps will send this URL and an identifier of some sort to a web service. The web service will store this identifier and URL in a database, overwriting any previous records for that identifier. Therefore the web service only knows the latest URL for that user's push notification channel.
Your app could either retrieve the URLs for the intended recipients from the web service, and send the push notification payload itself to the Push Notification Service (PNS), or send a request to the web service and have the web service send the payload to the PNS. We use the second option because it minimizes the amount of data traffic from the the device.
- Edited by Steve 'Sly' Williams Saturday, August 28, 2010 11:48 PM Extra info
-
Sunday, August 29, 2010 2:06 AMExcellent information. I wasn't planning on making users create accounts, so is there another unique identifier that i could use to keep track of the device, so i know when a URL gets updated?
-
Sunday, August 29, 2010 10:56 AMThere is such a unique ID per device, but it's not exposed to 3rd party developers yet.
--
Ginny Caughey
Device Application Development MVP -
Sunday, August 29, 2010 11:01 AM
Hi Acid,
Some commentary here on background for that topic as it develops if you want to check it out.
-
Sunday, August 29, 2010 11:34 AM
For our games, we're using the player's Xbox LIVE gamertag as the identifier on the web service. Then we are asking the web service to send a push notification to the player's friends. The web service looks up the gamertags of the player's friends and if they have a push notification URL registered, it sends the payload to that URL.
This shows how you also need to know how to find or determine other identifiers on the web service so you can send notifications to them.
-
Monday, August 30, 2010 4:16 AM
I ended up creating a random string using IsolatedStorage. This way i can keep track of the individual install. I'm not sure how long it persists (reboots, hard resets, etc), but this lets me have a unique id without making a user create an account. it now updates the URL every time the program starts.
thanks!!
-
Monday, August 30, 2010 10:36 AMAnything you put into Isolated Storage should last until the app is uninstalled or the phone is hard-reset.
--
Ginny Caughey
Device Application Development MVP

