iOS Integration

This document will cover integration steps for iOS side of your ReactNative application.

Installation

Step 1: Install Package.

npm install @suprsend/react-native-sdk@latest
yarn add @suprsend/react-native-sdk@latest

NOTE: If you are upgrading the SDK version, run pod update inside ios folder.


Step 2: Adding Swift support and Bridge header

ReactNative iOS side is in Objective-C and our native iOS SDK is written in Swift language so its mandatory to add Swift support in your project. You can skip this step if you already have swift language support in your project.

  1. Open xcodeworkspace file inside iOS folder. This will open Xcode.
  2. Add Swift file to project like shown below.
2880
  1. Select Swift File and click on Next button.
  2. Now give a suitable name to your file and click Create.
  3. After that popup will be shown asking to configure Objective-C bridge header. Click on Create Bridge Header.

Thats it! your React native iOS project can now understand code written in Swift language.

Step 3: Inside PodFile change iOS platform version to 13 or greater if it's less than 13.

platform :ios, '13.0' // this version has to be 13 or greater

Step 4: Run pod install from inside iOS folder.

Step 5: SuprSend SDK needs an iOS deployment target of 11 or above, update the target as given in below image if needed.


Initialization

Step 1: In AppDelegate.m add the below code inside didFinishLaunchingWithOptions method, just before returning YES like below.

#import <UserNotifications/UserNotifications.h> //add this, needed as sdk internally depends on this package
#import <SuprSendSdk/SuprSendSdk-Swift.h> //add this

...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  SuprSendSDKConfiguration* configuration = [[SuprSendSDKConfiguration alloc] initWithKey:@workspace_key secret:@workspace_secret baseUrl:nil]; // add this line
  [SuprSend.shared configureWithConfiguration:configuration launchOptions:launchOptions]; // add this line
  return YES;

Replace workspace_key and workspace_secret with your workspace values. You will get both the tokens from Settings -> API keys in SuprSend dashboard.


Logging

By default the logs of SuprSend SDK are disabled. You can enable the logs just in debug mode while in development by the below condition.

suprsend.enableLogging(); // available from v2.0.2

// deprecated from v2.0.2
suprsend.setLogLevel(level)
suprsend.setLogLevel("VERBOSE")
suprsend.setLogLevel("DEBUG")
suprsend.setLogLevel("INFO")
suprsend.setLogLevel("ERROR")
suprsend.setLogLevel("OFF")