Question

I'm in a real trouble to achieve this goal. I'm developing a PhoneGap aplication and I'm going to deploy it to Android, iOS and Windows Phone as well.

I was able to use Apple Notification Service (APN) and Google Cloud Messaging without any problems, but I'm having a real bad time trying to do the same with my Windows Phone app.

Unlike APN a GCM I couldn't find a place to generate some code or download some certificate to integrate my app with a push notification service.

I'm trying to use this service to send push notification to Windows Phone with PHP http://phpwindowsphonepush.codeplex.com/

The example shows me this $uri="http://db3.notify.live.net/throttledthirdparty/01.00/123456789123456798"; //uri sended by Microsoft plateform but how do I register into their plataform in order to get a URI like this one?

Also, is this PHP Windows Phone Push the right choice for sending toast and tile notifications on Windows Phone? The documentation is very confusing and isn't clear on how to configure the server and the native code application, I'm lost.

Était-ce utile?

La solution

That URI in called notification channel, and it's the MPNS equivalents of the APNS Device Token and the GCM Registration ID. You can get it in your Windows Phone app code :

public MainPage()
{
    /// Holds the push channel that is created or found.
    HttpNotificationChannel pushChannel;

    // The name of our push channel.
    string channelName = "ToastSampleChannel";

    InitializeComponent();

    // Try to find the push channel.
    pushChannel = HttpNotificationChannel.Find(channelName);

    // If the channel was not found, then create a new connection to the push service.
    if (pushChannel == null)
    {
        pushChannel = new HttpNotificationChannel(channelName);

        // Register for all the events before attempting to open the channel.
        pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
        pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

        // Register for this notification only if you need to receive the notifications while your application is running.
        pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

        pushChannel.Open();

        // Bind this new channel for toast events.
        pushChannel.BindToShellToast();

    }
    else
    {
        // The channel was already open, so just register for all the events.
        pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
        pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

        // Register for this notification only if you need to receive the notifications while your application is running.
        pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

        // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
        System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
        MessageBox.Show(String.Format("Channel Uri is {0}",
            pushChannel.ChannelUri.ToString()));

    }
}

You don't have to authenticate your web service (unauthenticated web services can send 500 message per device per day), but it is recommended to do so :

We recommend setting up an authenticated web service to send your notifications to the push notification service because communication occurs over an HTTPS interface for better security. Authenticated web services do not have a daily limit on the number of push notifications they can send. Unauthenticated web services, on the other hand, are throttled at a rate of 500 push notifications per subscription per day. For more info, see Setting up an authenticated web service to send push notifications for Windows Phone.

Relevant links :

Sending push notifications for Windows Phone

Setting up an authenticated web service to send push notifications for Windows Phone

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top