Skip to main content
Skip table of contents

SDK Documentation

SDK Integration Overview

As a partner you can interact with 11Sight’s system using this External API. Functions that allow you to complete various tasks can be found in the API Reference section.

You need to have a partner account and a token in order to make requests to the External API. A token is a secret identifier that is unique for each partner and should be sent in the header when making requests.

Tokens are secret values that should not be shared with third parties, since whoever has the token can make changes to your subscribers and services that are offered to them.

Tokens are assigned to each partner by 11Sight administrators. To receive a token, please contact Sales. if you already have asked for a token, please contact Support.

Selecting the Correct Environment

Selecting the correct environment

We have two different environments you can use with the SDK: Production and Sandbox.

Sandbox environment can be reached using this URL. This is for testing and development purposes only and should only be used for testing.

Production environment can be reached using this URL and is for production purposes.

When you are making a development, you can use the Sandbox environment freely to create users, make calls etc. When your app is released, you need to connect to the Production environment. If you use Sandbox environment on your released apps, you can experience problems.

You need to setup Production and Sandbox environments separately.

Initial Setup

Initial Setup

In order to start with the 11Sight API, you need to have a user account. To get a user account, please contact Support.

After logging to the site https://sdk.11sight.com/user/sign_in with your user name and password, you need to setup Apple and/or Google certificates in order to receive notifications and start integrating with the SDK. These certificates should be entered in the Partner Manager section.

You can see a list of your users and their basic call statistics. You can also see their buttons and call them, if needed.

Option

Description

iOS Production Certificate

This is the Apple Push Notification certificate which you can get from the Apple Developer portal. Push certificate should be able to send voip type notificaiton as well please choose corret one from developer portal while creating. You need to provide the file with pem extension which you can export from Keychain app in Mac OS. Pem file should contain both the certificate and private key.

iOS Bundle Id

This is your iOS app's bundle id.

Android FCM Key

This is the FCM (or GCM) key that you should obtain from Google Console to send messages.

Android App Key

This is the secret app key associated with your app.

Android Bundle Id

This is your Android app's bundle id.

If you will only use the iOS app, you don't need to fill in Android related options (or vice versa).

This information is required to send push notifications to your app when a call is initiated for the logged in user. When these options are not provided, logged in users on your app will not be able to receive calls when the app is in the background. But they can still receive calls when the app is open and in the foreground.

Once these options are set you, are ready for the SDK integration.

How to start with App SDK

After setting up your certificates and keys, you need to add our SDK to your app. SDK provides a complete package for you that handles everything related to call management. All you have to do is integrate the SDK inside your app, initialize it and add our push notification check code in notification handling.

In the next two sections, we will describe how to do the above for iOS and Android platforms.

iOS

General Info About SDK

SDK is not compatible with iOS Simulator because of SIP libraries.

SDK comes with persistent login feature, so you don't need to login every time app becomes active, you should call login once, then the SDK will handle rest of it. Same is true for logging users out.

SDK implementation expects a certain code implementation order to fulfill call structure. None of the SDK methods should be called twice in a row.

Adding SDK to the project

Adding SDK to the project

Minimum requirements to use our SDK are:

  • iOS13

Adding Library

You have two options to integrate 11Sight SDK to your project: CocoaPods or Manual Installation. You can use whichever option you want.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

CODE
$ gem install cocoapods

To integrate IISightSDK into your Xcode project using CocoaPods, specify it in your Podfile:

CODE
target '<Your Target Name>' do
    pod 'IISightSDK'
end

Then, run the following command:

CODE
$ pod install
Manual Installation

If you prefer not to use CocoaPods, you can integrate IISightSDK into your project manually.

You need to complete the following steps to integrate the SDK.

Please click here to download SDK.

  • Download IISightSDK and unzip it to your preferred folder

  • Select your application project in the Project Navigator (blue project icon)

  • Navigate to the target configuration window

  • Select the application target under the Targets heading in the sidebar

  • In the tab bar at the top of that window, open the General panel

  • Drop IISighSDK.framework under Embedded Binaries section

It should appear under Linked Frameworks and Binaries as well.

Setting Up Project Options

Once you have integrated the SDK either using CocoaPods or manual integration, you need to add the set some values in the project configuration files.

Add capabilities
  • Select your application project in the Project Navigator

  • Navigate to the target configuration window

  • Select the application target under the Targets heading in the sidebar

  • In the tab bar at the top of that window, open the Capabilities panel

  • Enable Push Notifications

  • Enable Background fetch, Background processing, select Audio, AirPlay, and Picture in Picture and Voice over IP

Info.plist

Add the following keys to your Info.plist file

  • Privacy - Media Library Usage Description

  • Privacy - Camera Usage Description

  • Privacy - Microphone Usage Description

  • Privacy - Photo Library Usage Description

Using IISightSDKManager

Using IISightSDKManager

This part of the document details how you will use the various functions of the integrated SDK.

AppDelegate

In order to start using our library you need the add this code block to the AppDelegate file. This code block will initialize our SDK.

You have to change YOUR_PARTNER_URL section with the address you will connect to the SDK. For Sandbox you need to use http://sdktest.11sight.com and for Production you need to
use http://sdk.11sight.com.

If you want to define a custom URL address, please contact our support on how to do this:

CODE
@import IISightSDK;
@interface AppDelegate ()<UNUserNotificationCenterDelegate> @end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if( !error ){
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
[[IISightSDKManager sharedManager] startWithPartnerUrl:@"YOUR_PARTNER_URL"];
return YES; }
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
if ([response isKindOfClass:[UNTextInputNotificationResponse class]]) { UNTextInputNotificationResponse *reply = (UNTextInputNotificationResponse *)response; BOOL belongsToSDK = [[IISightSDKManager sharedManager]
localNotificationBelongsToIISight:response.actionIdentifier content:reply.userText];
}else{
BOOL belongsToSDK = [[IISightSDKManager sharedManager]
localNotificationBelongsToIISight:response.actionIdentifier content:nil]; }
completionHandler();
}
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
BOOL belongsToSDK = [[IISightSDKManager sharedManager] localNotificationBelongsToIISight:notification.request.content.categoryIdentifier content:nil];
completionHandler(UNNotificationPresentationOptionAlert);
}
-(void)application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
IISightSDKManager.shared().setApnsNormalToken(deviceToken.map { String(format: "%.2hhx", $0) }.joined().base64EncodedString());
}
-(void)application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
BOOL belongsToSDK = [[IISightSDKManager sharedManager] remoteNotificationBelongsToIISightuserInfo];
completionHandler(UIBackgroundFetchResult.newData);
} }
Sign in

Use this function to log the user into our system. If the user is not logged in, s/he cannot receive a call.

CODE
IISightSDKLoginDelegate need to be set to class
- (void) login {
[[IISightSDKManager sharedManager] setLoginDelegate:self];
[[IISightSDKManager sharedManager] login_userWithEmail:@"USERNAME" password:@"PASSWORD"];
}
/*!
loginSuccessfulWithUserInfo will include following keys "user_id", "can_access_vcall",
"can_access_vcall_pro", "can_access_vmeet". Values will change based on user's capability.
*/
-(void)loginSuccessfulWithUserInfo:(NSDictionary * _Nullable)userInfo { // Login successful
}
-(void)loginFailedWithErrorMessage:(NSString *)errorMessage {
// Login failed
}
Making a call

When a video-button is pressed, this function needs to be called with the button_id for the user which we want to initiate the call.

CODE
- (void) makeCall { /*
* AvailablecallTypes=[.Video,.Audio,Chat]
*/
[[IISightSDKManager sharedManager] startOutgoingCall:@"BUTTON_ID" trackerId:nil callType:IISightCallType.Video];
}
Call Kit feature

11Sight provides a call kit feature for incoming calls, starting with iOS13 we make it mandatory because of Apple's restrictions. 11Sight will present a call kit with received audio and video calls, for chat call it will use a normal banner notification.

Sign out

If a user doesn't want to receive any calls or messages, they should be logged out. We are providing another function "availability" that you can use to make a user un-available for a period of time.

CODE
IISightSDKLogoutDelegate needs to be add set to class
- (void) logout {
[[IISightSDKManager sharedManager] setLogoutDelegate:self]; [[IISightSDKManager sharedManager] logout_user];
}
- (void) logoutSuccessful{ // Successful sign out
}
- (void) logoutFailedWithErrorMessage:(NSString *)errorMessage{
// Sign out failed
}
Call Status Information

If you want to get call status updates from SDK you can do following:

CODE
/*!
@brief When incoming call receive this delegate with call with call status.
*/
@protocol IISightCallStatusDelegate <NSObject>
-(void)callReceived:(NSDictionary*_Nullable)call_data; -(void)callAnswered:(NSDictionary*_Nullable)call_data; -(void)callEstablished:(NSDictionary*_Nullable)call_data; -(void)callEnded;
-(void)callFailed; @end
//MARK: IISight Call State Delegates
/*
Hash will contain "callee_name", "caller_name", "call_id"
*/
func callReceived(_ call_data: [AnyHashable : Any]?) {
print("IISight call received with info: \(String(describing: call_data))")
}
/*
Hash will contain "call_id"
*/
func callAnswered(_ call_data: [AnyHashable : Any]?) {
print("IISight call answered, info: \(String(describing: call_data))") }
/*
Hash will contain "call_id"
*/
func callEstablished(_ call_data: [AnyHashable : Any]?) {
print("IISight call established, info: \(String(describing: call_data))")
}
func callEnded() {
print("IISight call ended") 
}
func callFailed() {
print("IISight call failed")
}
Call Types

We are supporting following call types:

CODE
typedef NS_ENUM (NSUInteger, IISightCallType) {
  Video = 0,
  Audio = 1,
  Chat=2
};
Properties

SDK Manager also contains some properties that can be useful when using the SDK. Current user id. Guest/unauthorized userId is -1.

CODE
@property (nonatomic, readonly) NSInteger userId;

Authorization status property shows if the user is logged in or not. Users who are not logged in cannot receive calls.

CODE
@property (nonatomic) BOOL isLoggedIn;

Current connection status defines if the device is connected to the 11Sight server or not. If the user is offline or cannot establish a connection to the 11Sight servers the status of this property will change.

App should:

CODE
@property (nonatomic, assign) IISightConnectionStatus currentConnectionStatus;

You can also set your own ringtone for notifications. Ringtone file name with extension only (Ex. "ringtone.wav")

CODE
@property (nonatomic, strong) NSString * ringtone;

You can use this property to set custom image to Callkit screen app icon, otherwise system will automatically use AppIcon:

CODE
@property (strong, nonatomic) UIImage * _Nullable callkitImage;
Push Notification Handling

Push Notification Handling

If your application uses Push Notifications, there is a method which can help you to differentiate whether received notification belongs to SDK or not.

CODE
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification
*)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{ BOOL belongsToSDK = [[IISightSDKManager sharedManager] localNotificationBelongsToIISight:
notification.request.content.categoryIdentifier content: nil]; 
if (belongsToSDK) {
  NSLog(@"11sight notification"); 
  }
  else
  {
  NSLog(@"App notification"); 
  }
}

Android

Adding SDK to the project

Adding SDK to the project

Minimum requirements to use our SDK are:

  • minSdkVersion 21

Manual Setup For Android Studio Version below 4.2.1
Importing
  • Download IISightSDK and to your preferred folder.

  • Next, navigate to File - New - New Module

  • In the dialog select “Import .JAR/ .AAR Package” then click “Next”.

  • Enter the location of the compiled AAR or JAR file then click Finish.

  • Make sure the library is listed at the top of your settings.gradle file, as shown here for a library named "my-library":

  • CODE
    include ':app', ':sdkApp-amsip-public-release'
build.gradle (Module: app)
  • Open the app module's build.gradle file and add a new line to the dependencies block as shown in the following snippet:

CODE
dependencies
{
  implementation project(":sdkApp-amsip-public-release")
}
For Android Studio Version 4.2.1 onwards

Copy and Paste your downloaded .aar file to YourStudioProject/app/libs

CODE
dependencies
{
implementation files('libs/dkApp-amsip-public-release.aar') 
}
  • Also we need to add following libraries that IISightSDK use.

CODE
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation('org.squirrelframework:squirrel-foundation:0.3.8') {
exclude(group: 'javaassist', module: 'javassist')
exclude(group: 'dom4j', module: 'dom4j')
exclude(group: 'org.slf4j', module: 'slf4j-log4j12')
exclude(group: 'log4j', module: 'log4j')
exclude(group: 'org.mvel', module: 'mvel2')
exclude(group: 'com.google.code.gson', module: 'gson')
}
implementation "com.google.android.exoplayer:exoplayer:2.9.2"
implementation 'com.inrista.loggliest:loggliest:0.2'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'org.slf4j:slf4j-api:1.7.5'
implementation 'com.github.tony19:logback-android-classic:1.1.1-3'
implementation 'com.github.tony19:logback-android-core:1.1.1-3'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.otaliastudios:cameraview:1.5.0'
implementation 'com.google.gms:google-services:4.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
Firebase Setup
  • Go to https://console.firebase.google.com and add a project

  • In the project overview add an android mobile app

  • Follow the firebase instructions there:

    • Fill android package name, app nickname (optional) and SHA-1 (optional)

    • Download google-services.json.

    • Switch to the Project view in Android Studio to see your project root directory.

    • Move the google-services.json file you just downloaded into your Android app module root directory.

    • The Google services plugin for Gradle loads the google-services.json file you just downloaded. Modify your build.gradle files to use the plugin:

      • Project-level build.gradle (<project>/build.gradle).

      • App-level build.gradle (<project>/<app-module>/build.gradle).

      • Finally, press Sync now in the bar that appears in the IDE.

  • Go to the app’s settings, click “Cloud Messaging” tab and copy Server Key Token

  • Go to 11Sight’s partner manager settings, paste token in the Android FCM/GCM Key field and click save.

Using the IISightSDKManager

Using

This part of the document details how you will use the various functions of the integrated SDK.

Server Configuration

In order to start using our library you need the add this code block to the res/values/serverConfigWeb.xml file.

This code block will initialize our SDK.

You have to change PARTNER_URL section with the address you will connect to the SDK. For testing you need to use https://sdktest.11sight.com and for Production you need to
use https://sdk.11sight.com.

If you want to define a custom URL address, please contact our support on how to do this:

CODE
<resources>
<string name="server_config_web_address">PARTNER_URL</string> 
<string name="server_config_web_auth_username"></string> 
<string name="server_config_web_auth_password"></string>
</resources>
IISight SDK Manager initialization

Initialize IISightSDKManager in Application class. In our example we’re using SDKManager.class

CODE
import android.content.Intent;

import com.elevensight.elevensightsdk.IISight;
import com.elevensight.elevensightsdk.sdk.IISightSDKManager;

public class SDKManager extends Application implements IISightSDKManager.ICallback { 
private static IISightSDKManager sdkManager;

@Override
public void onCreate() { super.onCreate();
try { IISightSDKManager.build(this);
} catch (Exception e) {
e.printStackTrace(); 
}
sdkManager = IISightSDKManager.getInstance(); }

public static IISightSDKManager getSdkManager() {
return sdkManager; }

@Override
public void process(Object o) {
Intent i = new Intent(getApplicationContext(), Activity.class); 
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
getApplicationContext().startActivity(i);
}
}
For Xioami Phones

We have to ask users to allow 2 more permissions in cases where Xiaomi is the manufacturer of the mobile device.

CODE
import android.app.AlertDialog;

/**
* @author IISight Developer
 * @version 1.0
*/

public class PermissionsActivity extends BaseActivity { private AlertDialog.Builder otherSettingsDialog;

@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_permissions);
showOtherPermissionsDialog();
}

private void showOtherPermissionsDialog() { otherSettingsDialog = new AlertDialog.Builder(this)
.setMessage(getString(R.string.other_setting_permission))
.setCancelable(false)
.setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

@Override
public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss();

try {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR"); intent.setClassName("com.miui.securitycenter",
"com.miui.permcenter.permissions.PermissionsEditorActivity"); intent.putExtra("extra_pkgname", getPackageName()); startActivityForResult(intent, PermissionHelper.REQUEST_OTHER_PERMISSIONS);
} catch (Exception e) { e.printStackTrace();
}
}
}); 
otherSettingsDialog.show();
} 
}

Add this to string.xml

CODE
<string name="other_setting_permission">Please allow Show on Lock screen permission and Display pop-up window while running in the background to receive the calls when device is locked or completely closed</string>
Sign in
CODE
SDKManager.getSdkManager().loginUser(email, password, context, new IISightSDKManager.ICallback() {@Override
public void process(Object o) { // Success
}
}, new IISightSDKManager.ICallback() { @Override
public void process(Object o) { // Fail
}
});
Making a call
CODE
SDKManager.getSdkManager().makeCall((Context context, OutgoingCallType callType, String buttonId);
Android 10 Receiving Calls

When app is in background you need to add overlay permission for Android 10.

CODE
(application as DemoApplication).getSDKManager().checkOverlayPermissionDialog(this)
Receive a call

You don need to anything special for receiving a call.
Tip: If you can make a call but there is no receiving call, check firebase integration part.

Sign out
CODE
SDKManager.getSdkManager().logoutUser(new IISightSDKManager.ICallback() { @Override
public void process(Object o) {
// Success
}
}, new IISightSDKManager.ICallback() { @Override
public void process(Object o) { // Fail
}
});
Push Notification Handling

Push Notification Handling

If your application uses Push Notifications, there is a method which can help you to differentiate whether received notification belongs to SDK or not.

CODE
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(final RemoteMessage remoteMessage) {
// isIISightNotification returns true if notification comes from 11Sight and false if it's comes
from another server
boolean check = SDKManager.getSdkManager().isIISightNotification(remoteMessage,
MyFirebaseMessagingService.this);
if (check) {
// Handle 11Sight notification SDKManager.getSdkManager().handleIISightNotification(remoteMessage);
}else{
// Handle message from other servers
}
}
}

Important: handleIISightNotification() method handles incoming calls and has to be implemented.

User ID

User ID

You may need user id or user email. You can get user id or user email from Session object

CODE
Session.getInstance().getUserId()
Session.getInstance().getUserEmail()
Listen Call Events

Listen Call Events

CODE
Session.getInstance().setActiveCallListener(new ActiveCallListener() {

@Override
public void onCallReceived(String callId, String callerName, String calleeName, JSONObject formFields) {
}
@Override
public void onCallEnded(String callerName, String calleeName, long duration, JSONObject milestones) {
} @Override
public void onCallEstablished(String callId) {
}
@Override
public void onCallAnswered(String callId) {
}
@Override
public void onChatClicked(String callId) {
}
@Override
public void onCallFailed(String callId, JSONObject milestones) { }
});
How to use RESTful API

How to use RESTful API

External API allows you to communicate with the 11Sight SDK Server. You can create users, fetch their calls, get information related to calls and so on. You can connect to the External API by making REST requests to the API. Base URL which you need to make requests
is https://sdk.11sight.com for Production and https://sdktest.11sight.com for Sandbox.

As an example, to get the list of your subscribers you need to make a request with the following curl command:

CODE
curl "https://sdk.11sight.com/api/v2/users.json" \ 
-H "S-Auth-Token: YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d $'{}'

You should replace YOUR_TOKEN with your token. Each time you make a request to the External API you have to send this token in your headers. You will have a different token for each environment. Make sure that you are using the correct token for Production and Sandbox.

To see all the requests you can make with the RESTful API you can check the complete RESTful API Reference.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.