GeekPeek
GeekPeek

Reputation: 1767

Get the URI the MPNS to returns to the push client when creating a notification channel Windows Phone 7

/*Get the URI that the Microsoft Push Notification Service returns to the Push Client when creating a notification channel.
Normally, a web service would listen for URIs coming from the web client and maintain a list of URIs to send                
notifications out to. */

string subscriptionUri = TextBoxUri.Text.ToString();

Further information on how the pushclient would then sync the URI with a webservice lacks in the description given on MSDN. So, does anyone know how to make my app send its URI to the MPNS using the push notification client of the Windows Phone, iso having to manually copy-paste them into my web application? Greetz GP

Upvotes: 0

Views: 955

Answers (2)

impliciter
impliciter

Reputation: 61

See MSDN Windows Phone Code Samples at: http://msdn.microsoft.com/en-us/library/ff431744(v=vs.92).aspx

The following code snippet from the 'sdkToastNotificationCS' example show a possible location to store the uri or send to your webservice:

void PushChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
    {

        Dispatcher.BeginInvoke(() =>
        {
            // Display the new URI for testing purposes.   Normally, the URI would be passed back to your web service at this point.
            System.Diagnostics.Debug.WriteLine(e.ChannelUri.ToString());
            MessageBox.Show(String.Format("Channel Uri is {0}",
                e.ChannelUri.ToString()));
            // Instead of showing the URI in a message box, POST to your web service

        });
    }

Execute an HTTP POST request to send the URI and an identifier for you push user. Receive this POST data on your web service and store the user/URI so you can push notifications to that user from your web service.

Upvotes: 1

Matt Lacey
Matt Lacey

Reputation: 65566

You just need an endpoint on your server that the app can send the PNS uri (and any other relevant information) to.

Upvotes: 0

Related Questions