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

Getting Started with Push Notifications

Getting Started with Push Notifications

Implementing push notifications through Telerik Platform and the Backend Services iOS SDK gives you certain benefits. These include more easily registering a device for push notifications with the Apple Push Notification Service (APNS) and the ease of sending push notification from the Telerik Platform portal.

In this article you will learn how to integrate push notifications in a native iOS app.

Begin this tutorial by creating a new iOS > Application > Single View Application from Xcode.

Content at a glance:

  1. Download the SDK
  2. Include the Backend Services iOS SDK in Your Project
  3. Initialize and Register the Device for Push Notifications
  4. Run the App on a Connected Device
  5. Send a Push Notification

Prerequisites

Download the SDK

Open your Telerik Platform account and navigate to the Getting Started > Downloads screen in the top right corner. Click Backend Services to see a list of all available downloads. Choose your desired platform and download the ZIP archive to your local machine.

Include the Backend Services iOS SDK in Your Project

Unzip the archive containing the SDK and include the SDK in your project. Add the following statement to reference the SDK:

#import <EverliveSDK/EverliveSDK.h>

If you are working in a Swift project you need to add a bridging header to your project from Xcode by choosing File > New > File > iOS > Source > Header. Then add the statement above to the header. Register the bridging header under Build Settings > Swift Compiler > Code Generation with the relative path to the header, for example "MyBridgingHeader.h".

Initialize and Register the Device for Push Notifications

  1. Add the following code block in the didFinishLaunchingWithOptions event of your project's AppDelegate file. When the code is executed, the device will obtain a push token and register with Telerik Platform.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [Everlive setApplicationKey: @"your-app-id"];
    [application registerForRemoteNotifications];

    // Override point for customization after application launch.
    return YES;
}
 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    Everlive.setApplicationKey("your-app-id")

    application.registerForRemoteNotifications()

    // Override point for customization after application launch.
    return true
}
  1. Override the didRegisterForRemoteNotificationsWithDeviceToken method in the AppDelegate file:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken
{
    [Everlive setDeviceToken:newDeviceToken];
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    Everlive.setDeviceToken(deviceToken)
}

Run the App on a Connected Device

  1. Ensure that the device has an active Internet connection.
  2. Deploy and run the created app on your testing device. Note that the app will not run correctly in the simulator.

The device registers with Telerik Platform. Following that, you should be able to receive push notifications on your device.

Registered iOS Device in Telerik Platform

Send a Push Notification

  1. Open your Telerik Platform app.
  2. Navigate to Notifications > Push Notifications > Push Browser.
  3. Click Send a push notification and fill in the details.
  4. Click Send Now.

Send a push notification to iOS

See Also


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