Installation

1

Install Package.

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

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

2

Adding Swift support and Bridge header

This step is needed only if your react native project iOS side doesn’t support swift language.

To check for swift support in Xcode, open Project Settings --> Build Settings --> Swift Language Version (attached image). If entry is present, you already have swift support in your project.

If your project doesn’t support swift then its mandatory to add Swift support in your project by following the steps below.

  • Open “xcodeworkspace” file inside iOS folder. This will open Xcode.

  • Add Swift file to project like shown below.

  • Select Swift File and click on Next button.

  • Now give a suitable name to your file and click Create.

  • 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.

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
4

Run pod install from inside iOS folder.

pod install
5

Update the Target

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

Initialization

1

AppDelegate changes

In AppDelegate add the below code inside didFinishLaunchingWithOptions method, just before last returning line. Refer any one of code snippet below based on your projects AppDelegate file language.

#import <SuprSendSdk/SuprSendSdk-Swift.h> //add this

...

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

Replace workspace_key and workspace_secret

Replace the 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")