Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

Initializing and Registering a Device

Initializing and Registering a Device

Before you can send push notifications to a device that is running your app, you need to initialize and register it.

  • Initialization contacts the Microsoft Push Notification Service (MPNS) and enables your app to receive push notifications. This step includes acquiring a push token that authorizes Telerik Platform to send messages to the device.
  • Registration sets up Telerik Platform to send push notification to the device. This step includes creating a registration object for the device that stores the device's push token along with other details in the Telerik Platform cloud. The registration object's fields can be used to target messages to specific devices or device types.

This article is organized as follows:

Prerequisites

For push notifications to work in your app, take the following actions:

Windows Phone

Include the following capabilities in your manifest file (or select them from the manifest editor):

  • ID_CAP_PUSH_NOTIFICATION
  • ID_CAP_IDENTITY_DEVICE
  • ID_CAP_NETWORKING

Windows Phone

Configure push notifications by following the instructions in this MSDN article: How to authenticate with the Windows Push Notification Service (WNS) (Windows Runtime apps).

Initializing a Device

Call the Initialize() method to initialize a device for push notifications. Before you do that, you need to ensure that the device can contact MPNS (can connect to the internet and the connection is not blocked by firewall devices).

await app.WorkWith().Push().CurrentDevice.Initialize(PushSettings).ExecuteAsync();

On success, the device receives a push notification token.

Use the PushSettings instance to specify initialization settings that are passed to MPNS. All available settings are presented in the next table.

Property Name Property Type Default Value Description
ChannelName string null The name of the channel to use for push notifications. If null, the default channel name is used. Normally you need to set this only if you have already created a notification channel in your app outside of the Backend Services .NET SDK.
AutoUpdateWhenChannelChanged bool true Specifies whether the device registration is automatically updated when the notification channel changes.
AutoBindToShellToast bool true Specifies whether push notifications are bound to toast notifications automatically. If set to true, the HttpNotificationChannel.BindToShellToast() method is invoked internally.
AutoBindToShellTile bool true Specifies whether push notifications are bound to tile updates automatically. If set to true, the HttpNotificationChannel.BindToShelTile() method is invoked internally.

Registering a Device

After you have successfully initialized the device, you need to register it with Telerik Platform so that you can send it notifications.

The Register() method compiles all required device data and stores it in Telerik Platform:

var result = await app.WorkWith().Push().CurrentDevice.Register().ExecuteAsync();

Adding the customDeviceParameters allows you to include custom registration parameters. Later you can use them in filter expressions to target the device with specific messages.

var customDeviceParameters = new DeviceParameters();
customDeviceParameters.Add("age", "26");
customDeviceParameters.Add("City", "London");

var result = await app.WorkWith().Push().CurrentDevice.Register(customDeviceParameters).ExecuteAsync();

Once this method completes successfully, you can send notification to the device from Telerik Platform.

See Also


Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.