[Aerogear-users] Need help to set-up java-mpns with java web application

Erik Jan de Wit edewit at redhat.com
Wed Nov 11 03:12:21 EST 2015

Hi Dharmendra,

So in the first case:
Install the aerogear-windows-push nuget package in your windows mobile app:

PM> Install-Package aerogear-windows-push

Install UPS and create an application and a mpns varaint then add the
following to your windows app:

protected override void OnNavigatedTo(NavigationEventArgs e)
    PushConfig pushConfig = new PushConfig() {
        UnifiedPushUri = new Uri(""), VariantId = "", VariantSecret = ""
    }; //[1]
    Registration registration = new MpnsRegistration();
    registration.PushReceivedEvent += HandleNotification;
void HandleNotification(object sender, PushReceivedEvent e)

Fill out [1] with the location of your UPS and the id and secret from your
Mpns variant

If you have done that correctly you'll see a installation on the UPS
console. Now you can use the Java Sender to send a message to UPS that will
in turn send it to your device.

PushSender defaultPushSender =


Other case without UPS

Register your app with Mpns yourself have a look at the source code of the
aerogear-windows-push to see how to register:

            const string channelName = "ToastChannel";

            var channel = HttpNotificationChannel.Find(channelName) ?? new

            var tcs = new TaskCompletionSource<string>();
            channel.ChannelUriUpdated += (s, e) => {
tcs.TrySetResult(e.ChannelUri.ToString()); };
            channel.ErrorOccurred += (s, e) => { tcs.TrySetException(new
Exception(e.Message)); };

            channel.ShellToastNotificationReceived +=

            return await tcs.Task;

Use java-mpns in your app directly to send a message to the device:


   MpnsService service = MPNS.newService().build();


   MpnsMessage notification = MPNS.newMessage()
       .tile().count(2).title("Tile message")
   String subscriptionUri = "https://..../" //need to get this from the device
   service.push(subscriptionUri, notification);

Downside to this approach is that when you have other clients like android
or ios then you'll need to manage the dispatching yourself that is where
UPS is handy and you need a way to get the subscriptionUri from the device
to your java backend.

On Tue, Nov 10, 2015 at 2:08 PM, Dharmendra Sahu <
dharmendra.sahu08 at hotmail.com> wrote:

> Hello,
> I have gone through your api and server and I want to use in my
> application.
> I have created windows mobile application.
> I want to use java-mpns api for push notification.
> I want to send push notification message from my java web-application to
> AeroGear UnifiedPush Server and Unified server to my windows mobile
> application.
> OR
> I would like to know if we could send push notification from my java web
> application to my windows mobile application.
> Thanks for your support and help.
> Thanks
> Dharmendra Sahu
> _______________________________________________
> Aerogear-users mailing list
> Aerogear-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-users

       Erik Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-users/attachments/20151111/16331fe5/attachment.html 

More information about the Aerogear-users mailing list