Skip to content

vanner/tenjin-ios-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Please see our Release Notes to see detailed version history.

For Unity-specific instructions, please visit https://github.com/Ordinance/tenjin-unity-sdk.

Tenjin iOS SDK (Deployment Version 6.0+)

Tenjin initialization:

  • If you use pods add pod 'TenjinSDK' to your Podfile then run pod install and skip to step 5!
1. Download the SDK's contents here
2. Drag libTenjinSDK.a and TenjinSDK.h to your project.
3. Add the following Frameworks to your project:
  • AdSupport.framework
  • StoreKit.framework
  • iAd.framework

Dashboard

4. Include the linker flags -ObjC and -all_load under your Build Settings

Dashboard

5. Go to your AppDelegate file, by default AppDelegate.m, and #import "TenjinSDK.h".
6. Get your API_KEY from your Tenjin Organization tab.
7a. In your didFinishLaunchingWithOptions method add:
[TenjinSDK sharedInstanceWithToken:@"<API_KEY>"];

Here's an example of what your integration should look like in your AppDelegate.m file:

#import "TenjinSDK.h"

@implementation TJNAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [TenjinSDK sharedInstanceWithToken:@"<API_KEY>"];

    //All your other stuff
    ...
}
7b. Alternate initialization to handle deep links from other services. (DO NOT USE 7a and 7b. You need to use only one.)

If you use other services to produce deferred deep links, you can pass tenjin those deep links to handle the attribution logic with your tenjin enabled deep links.

#import "TenjinSDK.h"

@implementation TJNAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  
    //get your deep link from your other 3rd party service
    NSURL *url = [NSURL withString: @"your_deep_link"];
    
    //if you have a deep link that's generated from a third party service then pass it to tenjin to handle the attribution of deep links holistically
    if(url) {
      [TenjinSDK sharedInstanceWithToken:@"<API_KEY>" andDeferredDeeplink: url];
    }
    else{
      [TenjinSDK sharedInstanceWithToken:@"<API_KEY>"]
    }

    //All your other stuff
    ...
}
8. Validate your live events by adding your Test Device and observing your events come through in the live Tenjin Diagnostic tab.

Tenjin purchase event integration instructions:


There are two ways to handle revenue events:

1. Pass (SKPaymentTransaction *) transaction and (NSData *)receipt object:

After a purchase has been verified and SKPaymentTransactionStatePurchased you can pass Tenjin the transaction which was purchased:

//Get the NSData receipt
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receiptData = [NSData dataWithContentsOfURL:receiptURL];

//Pass the transaction and the receiptData to Tenjin
[TenjinSDK transaction: transaction andReceipt: receiptData];

If you have subscription receipts, please be sure to add your IAP shared secret to your appropriate app in the Tenjin Apps Dashboard.

OR

2. Pass a transaction manually (usually this is necessary if purchases are not handled by Apple):

To use this method, you will need a productName, currencyCode, quantity, and the unit price of the transaction:

NSString *productName = @"product_1";
NSString *currencyCode = @"USD";
NSDecimalNumber *price = [NSDecimalNumber decimalNumberWithString:@"0.99"];
NSInteger quantity = 1;

[TenjinSDK  transactionWithProductName: productName
            andCurrencyCode: currencyCode
            andQuantity: quantity
            andUnitPrice: price];
  • ProductName -> The name or ID of your product
  • CurrencyCode -> The currency of your unit price
  • Quantity -> The number of products that are counted for this purchase event
  • UnitPrice -> The price of each product

Total Revenue calculated is: TotalRevenue = Quantity * UnitPrice

Tenjin custom event integration instructions:

NOTE: DO NOT SEND CUSTOM EVENTS BEFORE THE INITIALIZATION event (above). The initialization must come before any custom events are sent.

You can also use the Tenjin SDK to pass a custom event:

  • sendEventWithName: (NSString *)eventName and

You can use these to pass Tenjin custom interactions with your app to tie this to user level cost from each acquisition source that you use through Tenjin's platform. Here are some examples of usage:

//send a particular event for when someone swipes on a part of your app
[TenjinSDK sendEventWithName:@"swipe_right"];

Custom events can also pass an NSString eventValue. Tenjin will use this eventValue as a count or sum for all custom events with the same eventName. The eventValue MUST BE AN INTEGER. If the eventValue is not an integer, we will not send the event.

Tenjin deferred deeplink integration instructions:

Tenjin supports the ability to direct users to a specific part of your app after a new attributed install via Tenjin's campaign tracking URLs. You can utilize the registerDeepLinkHandler handler to access the deferred deeplink through params[@"deferred_deeplink_url"] that is passed on the Tenjin campaign tracking URLs. To test you can follow the instructions found here.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //initialize the Tenjin SDK like you normally would for attribution
    [TenjinSDK sharedInstanceWithToken:@"<API_KEY>"];

    //If you want to utilize the deeplink capabilities in Tenjin, utilize the registerDeepLinkHandler to retrieve the deferred_deeplink_url from the params NSDictionary object
    [[TenjinSDK sharedInstance] registerDeepLinkHandler:^(NSDictionary *params, NSError *error) {
        if([params[@"clicked_tenjin_link"] boolValue]){
            if([params[@"is_first_session"] boolValue]){
                
                //use the params to retrieve deferred_deeplink_url through params[@"deferred_deeplink_url"]
                //use the deferred_deeplink_url to direct the user to a specific part of your app
                
            } else{

            }
        }
    }];
}

You can also use the v1.7.2+ SDK for handling post-install logic using the params provided in this registerDeepLinkHandler. For example, if you have a paid app, you can register your paid app install in the following way:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //initialize the Tenjin SDK like you normally would for attribution
    [TenjinSDK sharedInstanceWithToken:@"<API_KEY>"];

    //If you want to utilize the deeplink capabilities in Tenjin, utilize the registerDeepLinkHandler to retrieve the deferred_deeplink_url from the params NSDictionary object
    [[TenjinSDK sharedInstance] registerDeepLinkHandler:^(NSDictionary *params, NSError *error) {
        
          if([params[@"is_first_session"] boolValue]){
              //send paid app price and revenue to Tenjin
              
          } else{

          }
        
    }];
}

About

Tenjin iOS SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 50.7%
  • Ruby 49.3%