Push Notification helps you in sending event or alert to your app users even when they are not logged into the app. App42 uses MPNS (Microsoft Push Notification Service) to send Push Notification on Windows Phone. App42 currently supports Toast and Tile notifications for Windows Phone. You can send push notifications from UI console as well as can use APIs to send and schedule Push notification to your app users. App42 also gives you interesting insight about analytics of push messages too. Here are the few easy steps to get started with App42 Push Notification using a sample project in a few minutes.
Register with App42 platform
Create an app once you are on Quick-start page after registration.
If you are already registered, login to AppHQ console and create an app from App Manager -> App Create link.
Download sample project from our GitHub Repo
Unzip the downloaded file and open it in Microsoft Visual Studio Express for Windows Phone.
Open MainPage.xaml.cs file and put your API KEY and SECRET KEY which you have received after the success of app creation from AppHQ Console in the code Snippet which has been shown below and also put value of userId which you want to register for push notifications.
If you want to go into detail about the sample code, please see MainPage.xaml.cs which does all MPNS related work like registering with MPNS and App42 server and generating notifications. Once your app gets registered with MPNS, its PushChannel_ChannelUriUpdated method gets invoked.
For Toast Notifications we use “BindToShellToast” and for Tile Notification we use “BindToShellTile” method on channel to register channel to receive notifications.
The Above snippet will do all the stuff for you seamlessly. Once app will get started it will register your app with MPNS as well as with App42 platform for push notification usage. It uses StoreDeviceToken method to register app with App42 server.This is only one time activity and will be done when app will be opened.
Build your project and run.
Once your app is registered you are ready to send message to your app user using following code snippet from any App42 SDK. Below is the snippet for App42 Windows Phone SDK. If you want to send it from other SDK you can do it in the same way.
While using Tile Notifications we have to set “backBackgroundImage” and “backgroundImage”, either we can set a web Image URI or We can set the path of image existing at the device. Tile Notifications will appear on the main application title at HomeScreen of the device. When user clicks on that it opens the application.
From AppHQ Console
You can also send push messages to your registered app user directly from AppHQ console. To do this, go to AppHQ console and click on Push Notification -> Click on Users -> Select your App -> select your user from table and click on send push button. This will open a pop up to type your message, once you are done click on send button. This will trigger a push notification message to your app user.
You can also send tile notification from AppHQ by sending JSON formatted string e.g
App42 Push notification also supports channel subscription model where user can subscribe on channel of his interest to receive the notification. You can send message to channel which will deliver message to all users who are subscribed to that channel. A channel can be create from AppHQ console. Go to Push Notification ->Click on Channels -> Select your App -> Click on add channel button
Once channel is created you can ask user for subscription on the channel. Below is the code snippet for the same
You can also schedule message to your app user on specified time from AppHQ console. To do this, go to Push Notification -> Click on Users -> Select your app -> select target users/device and click on schedule push button.Now type your message in pop up and pass your time to schedule the message.
Message scheduling on channel can be done in similar way. Go to Push Notification -> Click on Channels -> Select your app -> select target channel and click on schedule push button.Now type your message in pop up and pass your time to schedule the message.
Once your device is registered for Push Notification you are ready to send multilingual(UTF-8) push message to your app user using following code snippet from any App42 SDK (Android/Java/WP etc)
For more details of Push Notification Documentation