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:
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:
MpnsService service = MPNS.newService().build();
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.