[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;
    registration.Register(pushConfig);
}
void HandleNotification(object sender, PushReceivedEvent e)
{
    Debug.WriteLine(e.Args.Message);
}


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 =
DefaultPushSender.withRootServerURL("http://localhost:8080/ag-push")
                .pushApplicationId("c7fc6525-5506-4ca9-9cf1-55cc261ddb9c")
                .masterSecret("8b2f43a9-23c8-44fe-bee9-d6b0af9e316b")
                .build();

See:
https://github.com/aerogear/aerogear-unifiedpush-java-client
https://github.com/aerogear/aerogear-windows-push
https://aerogear.org/docs/unifiedpush/ups_userguide/index/

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
HttpNotificationChannel(channelName);

            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 +=
PushChannel_ShellToastNotificationReceived;

            channel.Open();
            channel.BindToShellToast();
            return await tcs.Task;

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


   1.

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

   2.

   MpnsMessage notification = MPNS.newMessage()
       .tile().count(2).title("Tile message")
       .build();
   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
>
>


-- 
Cheers,
       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