Push Notification helps you in sending event or alert to your app users even when they are not logged into 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 notification 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 stated with App42 Push Notification using sample project in few minutes.
Download sample project from our GitHub Repo
Unzip the downloaded file and open it in Microsoft Visual Studio Express for Windows Phone.
Edit MainPage.xaml.cs file and put your API KEY and SECRET KEY as shown below and also modify userId variable with your App user name
If you want to go in 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 notification. 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.
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 device. Tile Notifications will appear on main application tile at HomeScreen of 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 User Link -> Select your App -> select your user from table and click on send message 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 -> Channel -> Select your App -> Click on Create 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, got to Push Notification -> Click on User link -> Select your app -> select target users/device and click on schedule message 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 Channel link -> Select your app -> select target channel and click on schedule message button.Now type your message in pop up and pass your time to schedule the message.