iOS SDK - Basic implementation

  1. System Requirements
  2. SDK Initialization
    1. Import Files
    2. Link the Static Library
    3. Initialize the SDK
    4. Advanced Settings
  3. Analytics Activation

1. System Requirements

The R1 Connect SDK supports all mobile and tablet devices running iOS 6.0 or newer with a base requirement of Xcode 4.5 used for development (Xcode 6.0 or newer is recommended). The downloadable directory (see below "a. Import Files") contains the library and headers for the R1 Connect SDK.

The library supports the following architectures (iOS version 6.0 and higher):

-arm7, arm7s, arm64 for deploying to physical devices

-i386, x86_64 for Simulator testing

2. SDK Initialization

a. Import Files

  1. Download the r1connect lib files: git clone git@github.com:radiumone/r1-connect-demo-iOS.git
  2. Open your iOS project in Xcode.
  3. Select File -> Add Files to “[YOUR XCODE PROJECT]” project
  4. Select all header files in the appropriate "Lib" Folder from the repo you just cloned. The "Bitcode Lib" is built for Xcode 7 version (with bitcode support). The "Non-Bitcode Lib" should only be used if you are building with Xcode 6.
  5. When the dialog box appears, check the Copy Items into destination group’s folder checkbox.

b. Link the Static Library

Go to "Build Phases" and make sure LibR1Connect.a file is set in the “Link Binary With Libraries” section. If absent, please add it.

Make sure you add:

  • libsqlite3.dylib
  • CoreLocation.framework
  • CoreBluetooth.framework
  • AdSupport.framework
  • CoreTelephony.framework
  • SystemConfiguration.framework

Verify that the Background Modes switch is turned on in the Capabilities tab for your target.

Also, it is important to add an entry to the 'Other Linker Flags' setting in your application's Build Settings in Xcode. Add '-ObjC' to the 'Other Linker Flags' setting if it is not already present. This is a common required flag when integrating static libraries with your code.

Integrate with your Swift project

If you are using Swift in your project and you want to use R1 Connect SDK in your swift code you should:

  • Open Build Settings for your project
  • Find Swift Compiler - Code Generation section
  • Add path to R1SDK-Bridging-Header.h file to Objective-C Bridging Header.

For example if SDK located in R1SDK folder inside your root project directory path will be $(PROJECT_DIR)/R1SDK/R1SDK-Bridging-Header.h

c. Initialize the SDK

You will need to initialize the R1 Connect Library in your App Delegate.

Import the required header files (Only for Objective C code)

At the top of your application delegate include any required headers:

#import "R1SDK.h"
#import "R1Emitter.h"

Initialize the R1Connect Instance

Note: The sdk.applicationID value is found in your RadiumOne Connect Dashboard under the Settings > Application tab. Do NOT use your Apple app ID, doing so will break your integration and prevent data from being sent.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {     
    R1SDK *sdk = [R1SDK sharedInstance];  

    // Initialize SDK
    sdk.applicationId = @"YOUR APPLICATION ID";  

    return YES; 
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    let sdk = R1SDK.sharedInstance();

    // Initialize SDK
    sdk.applicationId = "YOUR APPLICATION ID";

    return true
}

d. Feature Configuration

The following is a list of configuration parameters for the R1 Connect SDK. Most of these contain values that are sent to the tracking server to help identify your app on our platform and to provide analytics on sessions and location.

Configuration Parameters

applicationUserId

Optional current user identifier.

[R1SDK sharedInstance].applicationUserId = @"12345";
R1SDK.sharedInstance().applicationUserId = "12345";

cookieMapping

Enable or disable cookie mapping. By default is NO. Setting this first party cookie will enable RadiumOne to be effective in targeting the user for advertising campaigns run on behalf of the Publisher. Only enable this setting if you plan to run advertising with RadiumOne.

[R1SDK sharedInstance].cookieMapping = YES;
R1SDK.sharedInstance().cookieMapping = true;

deferredDeeplinkScheme

Enable deferred Deeplinking via Po.st.  Value is the app registered URL scheme.  This is optional but recommended.

[R1SDK sharedInstance].deferredDeeplinkScheme = @"your app scheme";
R1SDK.sharedInstance().deferredDeeplinkScheme = "your app scheme";

location

The current user location coordinates. Use only if your application already uses location services.

[R1SDK sharedInstance].location = [locations lastObject];
R1SDK.sharedInstance().location = …;

locationService

If your application did not use location information before this SDK installation, you can use locationService in this SDK to enable or disable it:

[R1SDK sharedInstance].locationService.enabled = YES;
R1SDK.sharedInstance().locationService.enabled = true;

N.B. - The Connect locationService uses the Location Manager in iOS. For deployment on iOS 8 and newer, it is required that the application's property list (plist) file include one of the two following keys:

NSLocationAlwaysUsageDescription
//provide location updates whether the user is actively using the application or not via infrequent background location updates
// OR
NSLocationWhenInUseUsageDescription
//provide location updates only while the user has your application as the foreground running app

These are string values that need to include a description suitable to present to a user. The description should explain the reason the application is requesting access to the user's location. Therefore, description you give should try to incorporate or reference the user benefit that may be possible through sharing location.

You must import R1LocationService.h to use this feature.

When enabled, such as in the example above, location information will be sent automatically. However, locationService doesn’t fetch the location constantly. For instance, when the location is received the SDK will turn off the location in CLLocationManager and wait 10 minutes (by default) before attempting to retrieve it again. You can change this value:

[R1SDK sharedInstance].locationService.autoupdateTimeout = 1200; // 20 minutes
R1SDK.sharedInstance().locationService.autoupdateTimeout = 1200; // 20 minutes

appName

The application name associated with the emitter. By default, this property is populated with the CFBundleName string from the application bundle. If you wish to override this property, you must do so before making any tracking calls.

[R1Emitter sharedInstance].appName = @"Custom application name";
R1Emitter.sharedInstance().appName = "Custom application name";

appId

Default: nil

The application identifier associated with this emitter. If you wish to set this property, you must do so before making any tracking calls. Note: that this is not your app's bundle id, like e.g. com.example.appname.

[R1Emitter sharedInstance].appId = @"12345678";
R1Emitter.sharedInstance().appId = "12345678";

appVersion

The application version associated with this emitter. By default, this property is populated with theCFBundleShortVersionString string from the application bundle. If you wish to override this property, you must do so before making any tracking calls.

[R1Emitter sharedInstance].appVersion = @"1.0.2";
R1Emitter.sharedInstance().appVersion = "1.0.2";

sessionTimeout

If positive, indicates how long, in seconds, the application must transition to the inactive or background state for before the tracker will automatically indicate the start of a new session when the app becomes active again by setting sessionStart to true. For example, if this is set to 30 seconds, and the user receives a phone call that lasts for 45 seconds while using the app, upon returning to the app, the sessionStart parameter will be set to true. If the phone call lasted 10 seconds, sessionStart will not be modified.

To disable automatic session tracking, set this to a negative value. To indicate the start of a session anytime the app becomes inactive or backgrounded, set this to zero.

By default, this is 30 seconds.

[R1Emitter sharedInstance].sessionTimeout = 15;
R1Emitter.sharedInstance().sessionTimeout = 15;

3. Feature Activation

a. Analytics Activation

Setup your App Delegate

(Only for Objective C code)

#import "R1SDK.h"
#import "R1Emitter.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  R1SDK *sdk = [R1SDK sharedInstance];

  // Initialize Analytics      
  sdk.applicationId = @"YOUR APPLICATION ID";  //Ask your RadiumOne contact for an app id

  // Start SDK
  [sdk start];

  return YES;
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    let sdk = R1SDK.sharedInstance();

    // Initialize Anlaytics
    sdk.applicationId = "YOUR APPLICATION ID";

    // Start SDK
    sdk.start();

    return true
}

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk