Windows Phone - Push Notification Guide
By Technical Support
#15 SDK Integration
SDK comes with the full source and a Sample Project. You can use an emulator while working with push notifications.
In order to integrate BulkPush into your application, follow the steps below.

1. Download our SDK package. If you develop for Windows Phone 8, add reference to BulkPushSDK/SDKBuild/WP8/ BulkPushSDK.dll to your project.
2. In the code add the BulkPushSDK namespace: using BulkPushSDK;
3. Initialize push service with the following code:

Code: Select all_service = NotificationService.GetCurrent("3A43A-A3EAB",null, null);
 
            _service.OnPushTokenReceived += (sender, args) =>
            {
            };
 
            _service.OnPushTokenFailed += (sender, args) =>
            {
            };
 
            _service.OnPushAccepted += (sender, args) =>
            {
               
            };
            _service.SubscribeToPushService();


First parameter – identifier of your application in BulkPush(required);
Second parameter – the name of the service for authenticated pushes, pass null if you don’t have one set-up;
Third parameter – a list of the trusted servers that could send Tile notifications (required for receiving Tile notifications).

4. Make sure you have enabled ID_CAP_PUSH_NOTIFICATION and ID_CAP_IDENTITY_DEVICE capabilities in your project. Expand the Properties folder in your Windows Phone application project and open WMAppManifiest.xml file.
You should enable ID_CAP_PUSH_NOTIFICATION and ID_CAP_IDENTITY_DEVICE capabilities by checking the corresponding checkbox.

That’s it! Easy, isn’t it?
Advanced features
Tags
Tags allow you to create a set of devices based on different criteria.

1. Create a list of tags:

Code: Select allvar tagsList = new List<keyvaluepair<string,object>>();
</keyvaluepair<string,object>


2. Add a tag to the list:

Code: Select alltagsList.Add(new KeyValuePair<string, object="">(“testKey”,“testValue”));
</string,>


3. Get the instance of NotificationService and send tags!

Code: Select allNotificationService service = NotificationService.GetCurrent();
 
_service.SendTag(tagsList,
   (obj, args) =>
   {
    MessageBox.Show("Tag has been sent!");
   },
   (obj, args) => MessageBox.Show("Error while sending the tags: \n" +
 
args.ToString())
 );


User Data
The application user can send any custom data to BulkPush with the custom tag.

1. Get the instance of NotificationService and get user data with the push notification (it also comes in the push notifications payload by the way!)

Geo zones
You can send push notifications to users located in a specific area.

1. Expand the Properties folder in your Windows Phone application project and open WMAppManifiest.xml file.
Enable ID_CAP_LOCATION capability by checking the respective checkbox. Thus, the application will be able to use the device location for the GeoZones feature.

Code: Select all<capabilities>
  <capability name="ID_CAP_NETWORKING">
  <capability name="ID_CAP_LOCATION"> // Enable this
 
capability to use geolocation s ervices
  <capability name="ID_CAP_PUSH_NOTIFICATION">
  <capability name="ID_CAP_IDENTITY_DEVICE">
  <capability name="ID_CAP_WEBBROWSERCOMPONENT">
  </capability></capability></capability>
</capability></capability></capabilities>


2. Turning Geo Zones on :

Code: Select allNotificationService service = NotificationService.GetCurrent();
service.StartGeoLocation();


3. Turning Geo Zones off :

Code: Select allNotificationService service = NotificationService.GetCurrent();
service.StopGeoLocation();