iOS SDK API

Interface Description

  1. JANALYTICSService class, including all interfaces of the statistics SDK

  2. JANALYTICSLaunchConfig class, counting SDK startup configuration model

  3. JANALYTICSEventObject class, counting event models


SDK Initialization

  • + (void)setupWithConfig:(JANALYTICSLaunchConfig *)config

    • Interface Description

      • Initialize the interface, it is recommended to call in application:didFinishLaunchingWithOptions:
    • Parameter Description

      • config:JANALYTICSLaunchConfig class
    • Call Example

    JANALYTICSLaunchConfig * config = [[JANALYTICSLaunchConfig alloc] init];
 
    config.appKey = @"your appkey";
     
    config.channel = @"channel";
     
    [JANALYTICSService setupWithConfig:config];

SDK Page Flow Statistics

  • + (void)startLogPageView:(NSString *)pageName

    • Interface Description

      • Interface to start page flow statistics. It is recommended to call in viewDidAppear: method of ViewControler
    • Parameter Description

      • pageName:The name of the page to start statistics
    • Call Example

    - (void)viewDidAppear:(BOOL)animated {
        [JANALYTICSService startLogPageView:@"first_page_flow"];
    }
  • + (void)stopLogPageView:(NSString *)pageName

    • Interface Description

      • Interface to end the page flow statistics is recommended to be called in the viewDidDisappear: method of the ViewControler. After the ending, the page is reported in a timely manner by default. It can be changed to a periodic reporting strategy through the [setFrequency:] method
    • Parameter Description

      • pageName:The page name to end the statistics
    • Call Example

    - (void)viewDidDisappear:(BOOL)animated {
        [JANALYTICSService stopLogPageView:@"first_page_flow"];
    }

SDK Location Statistics

  • + (void)setLatitude:(double)latitude longitude:(double)longitude

    • Interface Description

      • Report LBS information
    • Parameter Description

      • latitude

      • longitude

Call Example

[JANALYTICSService setLatitude:116.46 longitude:39.92];
  • + (void)setLocation:(CLLocation *)location

    • Interface Description

      • Report LBS information
    • Parameter Description

      • location: LBS class in CoreLocation.framework framework

Call Example

CLLocation * location = [[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(116.46, 39.92) altitude:50 horizontalAccuracy:50 verticalAccuracy:50 timestamp:[NSDate date]];
    [JANALYTICSService setLocation:location];

SDK Crash Log statistics

  • + (void)crashLogON

    • Interface Description

      • Turn on crash log collection, the default is off

Call Example

[JANALYTICSService setDebug:YES];

Log Level Settings

  • + (void)setDebug:(BOOL)enable

    • Interface Description

      • Set whether to print Debug level log information generated by sdk, and the default is NO (do not print log)
    • Parameter Description

      • enable: Set YES to enable, set NO to turn off

Call Example

[JANALYTICSService setDebug:YES];

Event Statistics

  • + (void)eventRecord:(JANALYTICSEventObject *)event

    • Interface Description

      • Custom events. Statistics of various events need to introduce different event models. For the specific event models, please see the event model description
    • Parameter Description

      • event:Object of event statistics

Descriptions of the incident statistics:

  1. The value of template attributes value is divided into non-empty and optional, refer to the following introduction

  2. Size of string attributes and custom attributes (key and value in extra) is limited not to exceed 256 bytes. The event will be discarded when there is an out of bounds.

  3. The number of custom key pairs cannot exceed 10, and more than 10, the event will be discarded.

  4. By default, events are reported immediately. It can be changed to a periodic reporting strategy through the [setFrequency:] method

  5. JANALYTICSEventObject

This model is a generic parent model and cannot be used alone.

Parameter Description

Parameter Name Parameter Type Parameter Description
extra NSDictionary Custom attributes

Login Event model

  • JANALYTICSLoginEvent

This model is a login event model, which can set parameters for date reporting.

Parameter Description

Parameter Name Parameter Type Parameter Description
method NSString Login method (not empty)
success BOOL Whether the login is successful (not empty)

Call Example

    JANALYTICSLoginEvent * event = [[JANALYTICSLoginEvent alloc] init];
     
    event.success = YES;
     
    event.method = @"login type";
     
    event.extra = @{@"custom key1":@"custom value"};
     
    [JANALYTICSService eventRecord:event];

Note:

    The following key values cannot be used in extension parameters in the login event model:

    login_method

    login_success

    This type of key is already used by the model, and using them will result in inaccurate statistics.

Register Event Model

  • JANALYTICSRegisterEvent

This model is a registered event model and can set parameters for data reporting.

Parameter Description

Parameter Name Parameter Type Parameter Description
method NSString Registration method (not empty)
success BOOL Whether the login is successful (not empty)

Call Example

    JANALYTICSRegisterEvent * event = [[JANALYTICSRegisterEvent alloc] init];
 
    event.success = YES;
 
    event.method = @"register type";
 
    event.extra = @{@"custom key1":@"custom value"};
 
    [JANALYTICSService eventRecord:event];

Note:

    The following key values cannot be used in extended parameters in the register event model:

    register_method

    register_success

    This type of key is already used by the model, and using them will result in inaccurate statistics.

Purchase Event Model

  • JANALYTICSPurchaseEvent

This model is a purchase event model and can set parameters for data reporting.

Parameter Description

Parameter Name Parameter Type Parameter Description
goodsID NSString Product id
goodsName NSString Product name
price CGFloat Purchase price (non-empty)
success BOOL Whether the purchase is successful (not empty)
currency JANALYTICSPurchaseCurrency Currency type. Currently only supports CNY/USD. Please refer to the JANALYTICSPurchaseEvent header file for details.
goodsType NSString Product types
quantity NSInteger Product quantity

Call Example

    JANALYTICSPurchaseEvent * event = [[JANALYTICSPurchaseEvent alloc] init];
 
    event.success = NO;
 
    event.price = 5388.0;
 
    event.goodsName = @"iphone7";
 
    event.goodsType = @"phone";
 
    event.quantity = 1000.1;
 
    event.goodsID = @"123456";
 
    event.currency = JANALYTICSCurrencyCNY;
 
    event.extra = @{@"custom key1":@"custom value"};
 
    [JANALYTICSService eventRecord:event];

Note

The following key values cannot be used in extended parameters in the purchase event model:

purchase_goods_id

purchase_goods_name

purchase_price

purchase_currency

purchase_goods_type

purchase_quantity

purchase_success

This type of key is already used by the model, and using them will result in inaccurate statistics.

Browse Event Model

  • JANALYTICSBrowseEvent

This model is a browse event model which can set parameters for data reporting.

Parameter Description

Parameter Name Parameter Type Parameter Description
contentID NSString Browse content id
name NSString Content name (not empty)
type NSString Content type
duration CGFloat Browse length

Call Example

  JANALYTICSBrowseEvent * event = [[JANALYTICSBrowseEvent alloc] init];
 
  event.name = @"browse name";
 
  event.type = @"browse type";
 
  event.contentID = @"browse id";
 
  event.duration = 1.2;
 
  event.extra = @{@"custom key1":@"custom value"};
 
  [JANALYTICSService eventRecord:event];

Note:

    The following key values cannot be used in the extended parameters in the browse event model:

    browse_content_id

    browse_name

    browse_type

    browse_duration

    This type of key is already used by the model, and using them will result in inaccurate statistics.

Count Event Model

  • JANALYTICSCountEvent

This model is a custom count event model which can set parameters for data reporting.

Parameter Description

Parameter Name Parameter Type Parameter Description
eventID NSString Event ID (not empty)

Call Example

  JANALYTICSCountEvent * event = [[JANALYTICSCountEvent alloc] init];
 
  event.eventID = @"event id";
 
  event.extra = @{@"custom key1":@"custom value"};
 
  [JANALYTICSService eventRecord:event];

Note:

    The following key values cannot be used in extended parameters in a custom count event model:

    event_id

    This type of key is already used by the model, and using them will result in inaccurate statistics.

Calculate Event Model

  • JANALYTICSCalculateEvent

This model is a custom calculate event model. The calculate event will be accumulated by different values of the same event, and the parameters can be set to report data.

Parameter Description

Parameter Name Parameter Type Parameter Description
eventId String Event Id (not empty)
value CGFloat The value of event (not empty)

Call Example

  JANALYTICSCalculateEvent * event = [[JANALYTICSCalculateEvent alloc] init];
 
  event.eventID = @"event id";
 
  event.value = 10.2;
 
  event.extra = @{@"custom key1":@"custom value"};
 
  [JANALYTICSService eventRecord:event];

Note:

    The following key values cannot be used in extended parameters in a custom calculate event model
    event_id
    event_value
    This type of key is already used by the model, and using them will result in inaccurate statistics.

SDK Sets Up User Information

  • + (void)identifyAccount:(JANALYTICSUserInfo *)userInfo with:(void (\\^)(NSInteger err, NSString * msg))completion

    • Interface Description

      • Bind user dimension
    • Parameter Description

      • userInfo:User information model

      • completion:Callback of error code and error message

Call Example

    JANALYTICSUserInfo * userinfo = [[JANALYTICSUserInfo alloc] init];
    userinfo.accountID = @"janalyticsID1";
    userinfo.creationTime = [[NSDate date] timeIntervalSince1970];
    userinfo.sex = JANALYTICSSexMale;
    userinfo.paid = JANALYTICSPaidPaid;
    userinfo.email = @"test@jiguang.cn";
    [userinfo setExtraObject:@"extraObj1" forKey:@"extrakey1"];

    [JANALYTICSService identifyAccount:userinfo with:^(NSInteger err, NSString *msg) {
    if (err) {
    NSLog(@"identify ERR:%ld|%@", err, msg);
    }else {
    NSLog(@"identify success");
    }
    }];

SDK Unbinds Current User Information

  • + (void)detachAccount:(void (\\^)(NSInteger err, NSString * msg))completion

    • Interface Description

      • Unbind the currently bound user dimension
    • Parameter Description

      • completion: Callback of error code and error message

Call Example

  [JANALYTICSService detachAccount:^(NSInteger err, NSString *msg) {
    if (err) {
      NSLog(@"detach ERR:%ld|%@", err, msg);
    }else {
      NSLog(@"detach success");
    }
  }];

SDK Sets Report Frequency

  • + (void)setFrequency:(NSUInteger)frequency

    • Interface Description

      • Set the periodic reporting frequency such as page flow/event

      • The default is not set frequency, but report timely

      • It can be set to 0, which means cancel the periodic report and change it to instant report.

    • Parameter Description

      • frequency:frequency of instant report, in seconds

      • Allowed frequency range: 0, or 10 - 24*60*60

Call Example

//e.g. 十分钟上报一次 
[JANALYTICSService setFrequency:600];

Technical Support

Email Contact: support@jiguang.cn


Copyright 2011-2020, jiguang.cn, All Rights Reserved.
粤ICP备12056275号-13 深圳市和讯华谷信息技术有限公司

Documentation built with MkDocs.