Initialize SDK

Prev Next

It is crucial for Insider’s iOS SDK to listen to certain AppDelegate methods to run and initialize the SDK before executing any other operation. It is highly recommended that the SDK be initialized right after the didFinishLaunchingWithOptions iOS native method inside the AppDelegate class. Please be informed that delaying the initialization of the SDK by other operations may result in inconsistencies with the SDK features.

You can follow these steps to initialize the SDK.

1. Open your AppDelegate.m or AppDelegate.swift file.
2. Import Insider header for Objective-C or Create Bridging-Header file for Swift.

AppDelegate

#import <InsiderMobile/Insider.h>
// Make sure you have Bridging-Header file.
#import <InsiderMobile/Insider.h>

3. Navigate inside the didFinishLaunchingWithOptions method.
4. Call initSDK.
5. Call registerWithQuietPermission to ask for push permission. You can also use your own methods to ask for push permission, if any.

your title goes here
Remember that "your_partner_name" is the given name of the app panel on the Insider side. You can gather this info from the Insider One team, or log in to the Insider panel and navigate it yourself. It is placed at the top right of the panel, next to the username.

AppDelegate

//  AppDelegate.h

// Make sure you have imported the below line in your AppDelegate.h file.
#import <UserNotifications/UserNotifications.h>

//  After the import, you need to extend the AppDelegate with UNUserNotificationCenterDelegate.

@interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>

//  AppDelegate.m
// DO NOT FORGET TO CHANGE THIS TO YOUR APP GROUP
static NSString *APP_GROUP = @"group.com.company.product";

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Make sure you have to below the line.
    UNUserNotificationCenter.currentNotificationCenter.delegate = self;

    // DO NOT FORGET to change "your_partner_name"
    // DO NOT USE any capital letters. Just use lowercase.
    [Insider initWithLaunchOptions:launchOptions partnerName:@"your_partner_name" appGroup:APP_GROUP];
    [Insider registerWithQuietPermission:false];

    return YES;
}
//  You need to extend the AppDelegate with UNUserNotificationCenterDelegate.

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate


// DO NOT FORGET TO CHANGE THIS TO YOUR APP GROUP
let appGroup = "group.com.company.product"

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // Make sure you have to the below line.
         UNUserNotificationCenter.current().delegate = self

        // DO NOT FORGET to change "your_partner_name"
        // DO NOT USE any capital letters. Just use lowercase.
        Insider.initWithLaunchOptions(launchOptions, partnerName: "your_partner_name", appGroup: appGroup)
        Insider.register(withQuietPermission: false)
        return true
}
Your title goes here
During your Integration, if you're using your UAT panel, update the "your partner name" value to migrate integration to the live panel.