Skip to content

Quick Start

Getting started with SendMan is fast and easy.
We've made the integration process accessible to both experienced developers who have implemented push notifications in mobile apps before and developers who are doing it for the first time.

If you want a detailed explanation of how to integrate push notifications in your app, head on over to our detailed integration guide.

Step 1: Install the SDK

SendMan can be installed via either CocoaPods or via Carthage

pod 'SendMan', '~> 1.0.0'
github "sendmanio/sendman-ios-sdk" ~> 1.0.0

Step 2: Configure Capabilities

In order to receive notifications, make sure your app matched the capabilities below.
Go to Target > Signing & Capabilities and check the following capabilities:

  1. Push Notifications
  2. Background Modes
    • Remote Notifications
Any other capabilities can be set depending on your app's needs.

Info

Our SDK supports iOS versions 10 and above.

Step 3: Integrate with Your Code

This is the heart of the integration, which we'll divide into two parts: SDK identification & abilities and token and analytics tracking.
It's probably not the final code structure you'd like to see in your app, but these snippets will take you through the entire integration in less than 5 minutes.

SendMan Initialization & Identification

SendMan has several requirements in order to fully function. While the gist of the requirements is here, we've also added a detailed integration section.

  1. Initializing the SDK: In order to communicate with our servers, you must identify the app (with a common config for all running app instances), and the individual user (in order to track and target different end users using SendMan).
    Get your app key and secret from the API keys screen.

    // Step 1: App-level identification: Initialize our SDK.
    SendMan.setAppConfig(SMConfig(key: YOUR_APP_KEY, andSecret: YOUR_APP_SECRET))
    
    // Step 2: User-level identification: Identify your users with the unique ID your application uses to identify users.
    SendMan.setUserId("some-unique-id")
    
    // Step 1: App-level identification: Initialize our SDK.
    [SendMan setAppConfig:[[SMConfig alloc] initWithKey:YOUR_APP_KEY andSecret:YOUR_APP_SECRET]];
    
    // Step 2: User-level identification: Identify your users with the unique ID your application uses to identify users.
    [SendMan setUserId:@"some-unique-id"];
    

    Info

    You should call these methods as soon as possible (not necessarily together); the SDK will start sending data to our servers only after they are set.

    If your users do not have unique IDs, use this syntax for us to automatically handle those users for you:

    SendMan.setAppConfig(SMConfig(key: YOUR_APP_KEY, andSecret: YOUR_APP_SECRET, autoGenerateUsers: true))
    
    [SendMan setAppConfig:[[SMConfig alloc] initWithKey:YOUR_APP_KEY andSecret:YOUR_APP_SECRET autoGenerateUsers:YES]];
    

    Attention Never use autoGenerateUsers and setUserId on the same app.

  2. Registering for push notifications with iOS: Calling the registration method will display the default OS-level push notification authorization dialog.

    SendMan.requestPushAuthorization()
    
    [SendMan requestPushAuthorization:nil];
    
    You may call this via our SDK function or through Apple's native functions.

    Tip

    Getting approval for push notifications from your users is a delicate procedure.
    Apple will only display the native popup once, so make sure you display it at a time your users are most inclined to agree to receiving notifications.

In order to make it easier for you to get insights on your users, you can register custom user properties using our SDK, as described in the 'Report Custom Properties' section.

Token & Analytics Tracking

Below is a concise version of an AppDelegate that shows how the OS-level callbacks work together with SendMan.

import SendMan

class AppDelegate: UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Set your AppDelegate as the delegate in charge of receiving notifications for the app from the OS.
        UNUserNotificationCenter.current().delegate = self

        // Track push notifications that have triggered an app launch
        SendMan.applicationDidFinishLaunching(options: launchOptions)

        return true;
    }


    // Handle token registration
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        SendMan.applicationDidRegisterForRemoteNotifications(withDeviceToken: deviceToken)
    }

    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        SendMan.applicationDidFailToRegisterForRemoteNotificationsWithError(error)
    }

    // Track a notification received while the app is in the foreground.
    func userNotificationCenter(_: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        SendMan.userNotificationCenterWillPresent(notification)
        completionHandler(.alert) 
    }

    // Track notifications that caused the app to move to the foreground when it was running in the background.
    func userNotificationCenter(_: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        completionHandler()
        SendMan.userNotificationCenterDidReceive(response)
    }
}
#import <SendMan/SendMan.h>

@implementation SMAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Set your AppDelegate as the delegate in charge of receiving notifications for the app from the OS.
    [UNUserNotificationCenter currentNotificationCenter].delegate = self;

    // Track push notifications that have triggered an app launch 
    [SendMan applicationDidFinishLaunchingWithOptions:launchOptions];

    return YES;
}

// Handle token registration
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [SendMan applicationDidRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    [SendMan applicationDidFailToRegisterForRemoteNotificationsWithError:error];
}

// Track a notification received while the app is in the foreground.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
    [SendMan userNotificationCenterWillPresentNotification:notification];
    completionHandler(UNNotificationPresentationOptionAlert);
}

// Track notifications that caused the app to move to the foreground when it was running in the background.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
    completionHandler();
    [SendMan userNotificationCenterDidReceiveNotificationResponse:response];
}

@end

Finish Configuration

This concludes the integration on your app's end.
In order to make everything work, you should now head to our console and configure your app as described in this 'Add Application' section.