Windows 8 - Push Notification Guide
By Technical Support
#19 SDK Integration

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.
2. Add reference to BulkPushSDK/SDKBuild/BulkPushSDK.winmd to your project
3. In the code add the BulkPushSDK namespace: using BulkPushSDK;
4. Initialize push service with the following code:

Code: Select allprivate void Subscribe_Tapped(object sender_, TappedRoutedEventArgs e)
        {
            try
            {
 
                string _BPId = BPID.Text;
               
                service =
                BulkPushSDK.NotificationService.GetCurrent(_BPId, "");
                if (Host.Text.EndsWith("/"))
                {
                    service.SetHost(Host.Text);
                }
                else
                {
                    service.SetHost(Host.Text + "/");
                }
 
                service.OnPushAccepted += (sender, pushNotification) => {
    //code to handle push notification
    string pushString = pushNotification.ToString(); //will return
 
json push payload
                };
                service.OnPushTokenReceived += (sender, pushToken) => {
//code to handle push token
                };
                service.OnPushTokenFailed += (sender, errorMessage) => {
 //code to handle push subscription failure
                };
                service.SubscribeToPushService();
             
            }
            catch (Exception ex)
            {
                MessageDialog dialog = new MessageDialog("Host does
 
not exist: \n" + ex.Message);
                dialog.ShowAsync();
            }
 
  }


5. In your App.xaml.cs in OnLaunched function add the following:
Important! If you plan to use Toast notifications, please make sure you have switched Toast notifications on in your application project. Go to the Application UI tab of your application manifest settings, and set Toast Capable to Yes. Otherwise Toast notifications will not work on the device.

Image

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 allobject[] Values = new object[] { "this is tag value"};
string[] Keys = new string[] { "this is tag name"};


2. Send tags to BulkPush:

Code: Select allservice.SendTag(Keys, Values)


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

1. Turning Geo Zones on:

Code: Select allservice.StartGeoLocation();


2. Turning Geo Zones off:

Code: Select allservice.StopGeoLocation();