Push data statistics products (number of) iOS integration practices

Source: Internet
Author: User
Tags install cocoapods

Recently the business parties to our department to provide new requirements, we hope to be able to count the application of several important data. This time we are trying to use a push (previously dedicated to message push) of its new product "number and application statistics", according to the official statement, a push of data statistics products through professional mobile application data analysis, can provide users with real-time data statistical analysis Services, including understanding version quality, Channel status, User portrait, etc. The data is visualized at the end of the presentation. We've been trying for a while, and the results are pretty good, and this article will show you how to quickly and efficiently integrate the number of IOS SDKs from scratch .

First, login account and create app get APP ID

1, visit the [ Push Developer Center ](https://dev.getui.com/dev/#/login), click Register Now:

(You can also enter the www.getui.com from a Twitter website , click "Developer Center" in the top right corner.) of course, if you have already registered a push-to-send account, you can log in and use it directly.

2. Fill in and register your account according to your personal situation:

3.return to [ Push Developer Center ](https://dev.getui.com/dev/#/login) login with the registered account of the last step, After entering the developer Platform Panel, select the number of menu bars on the left and apply statistics :

4.Enter the number • After applying the statistics panel, select the new app in the upper right corner to add the app:

5.fill in the application information, tick iOS, click Submit new app:

6, the new application will automatically return to the application list, find the new application, click on the application configuration:

7, under the configuration information can see the app ID, copy it to save, the subsequent integration will be used to the app ID:

second, the number of configuration Sdk

The IOS SDK provides two ways to integrate with CocoaPods integration and Xcode Manual integration, both of which are described in this article. Choose one of these when you integrate the SDK (we recommend using CocoaPods integration).

Third, CocoaPods Integration Method

1, installation CocoaPods

the installation is simple , with Rubyunder your Mac, and you can download the installation using Ruby 's gem command:

$ sudo gem install Cocoapods

$ pod Setup

2, prepare podfile

when using, you need to create a new one named Podfile files (which do not need to be recreated if they already exist), in the following format, list the dependent library names sequentially in the file:

Target ' yourtargetname ' do

Platform:ios, "8.0"

Pod ' GCSDK '

End

3. Complete gcsdk Import

will edit the good Podfile file into your project root directory, execute the following command:

$ CD "<path/to/project>"

$ pod Install

4, after using cocospods integration SDK , need to close the original project, re-open in the project root directory Yourprojectname.xcworkspace files for follow-up development:

Four, Xcode Integration Method

1, the number of application statistics provides an SDK Development Kit, contains all the required resources of the IOS SDK , go to a push document center download, address:/http docs.getui.com/download.html, number of options • iOS download SDK Resource Pack under app statistics:

2, extract the contents of the resource pack can see the following file structure:

3. Detailed description of resource package

Access Document / number integration document . PDF: Number of integrated documents ;

resource file /gtcountsdk.h: number of SDK header Files

resource file /libgtcountsdk.a: number of SDK main package Static library

resource file /libgtcommonsdk.a: number SDK Tool Library

Demo Project /gtcountdemo/: number of demo projects

4, note:libgtcountsdk.a,libgtcommonsdk.a use Lipo Tool will

The code that supports i386,x86_64,arm64,armv7 is packaged together, So this library will support both simulator and device, and the supported IOS versions are 7.0 and above.

5, the number of SDK static Library Settings

Right-click Add File to import the file under the resource file directory.

6. Add dependent libraries (must, such as)

Add System Library Support:

* LIBSQLIT3.TBD

* LIBZ.TBD

* Adsupport.framework

7. Set other Linker Flags

find the target of the main project -> Build Setting -> Linking -> Other Linker Flags, set it to -OBJC():

v. Initialize and start Sdk

1.Initialize the relevant information of the starting interface:

2. add a header file to theproject's appdelegate.m , Initialize and launch the SDKusing the APP ID previously obtained:

#import ' GTCountSDK.h '

#define KGCAPPID @ "xxxxxxx"

@implementation Appdelegate

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {

Startup number SDK

[Gtcountsdk startsdkwithappid:kgcappid withchannelid:@ "AppStore"];

use the reportstrategy property of the SDK instance to set the escalation policy.

[[Gtcountsdk sharedinstance] setreportstrategy:geshu_strategy_wifi_only]

gets The value of the sessiontime using the Sessiontime property of the SDK instance .

NSLog (@ "Sessiontime%ld", [[Gtcountsdk sharedinstance]sessiontime]);

return YES;

}

Vi. Advanced Features: Custom events

Custom events can count the time and number of times a user has customized a site, such as ad clicks, text messages, and so on. Typically event_id is used to represent a statistic of a behavior or function (such as how many times the "Send" button is triggered), while the parameter is used to identify the specific object of the statistic (such as a button with the function "Download"), by event_id and Properties uniquely identifies an event.

There are two main categories of custom events:

(1) Count: Counts the number of times a specified behavior has been triggered.

(2) Time-length statistics: The time that the specified behavior is consumed, in seconds. the eventbegin and eventend interfaces need to be used in pairs to take effect.

Each of these events supports the use of the properties parameter type.

Note:event_id needs to be configured in a Push developer Center (https://dev.getui.com/) before it can participate in normal data statistics. event_id cannot contain spaces or escape characters, as follows:

1. Click on the side menu bar Event list.

2. Click the Add Event button.

3.enter the corresponding event ID and event name, respectively, based on the event type .

4.add the corresponding event type and the corresponding event_id event in the Mobile project:

@implementation Trackcounteventcontroller

-(Ibaction) Clickcount: (ID) Sender {

[Gtcountsdk trackcountevent:@ "Countid1" withargs:@{@ "ckey1": @ "cvalue1"}];

}

-(void) Viewdidappear: (BOOL) Animated {

for proper statistics, ensure that the parameters of the start and end interfaces are self.eventproperty memory addresses.

Self.eventproperty = @{@ "key": @ "value1"};

[Gtcountsdk trackcustomkeyvalueeventbegin:@ "Eid1" withArgs:self.eventProperty];

[Super viewdidappear:animated];

}

-(void) Viewwilldisappear: (BOOL) Animated {

[Gtcountsdk trackcustomkeyvalueeventend:@ "Eid1" withArgs:self.eventProperty];

[Super viewwilldisappear:animated];

}

@end

Vii. Advanced Features: Data escalation policy

Number of application statistics can be customized data escalation policy, developers can be set according to their own application requirements, can effectively control user traffic overhead.

1, The data escalation policy of the SDK includes the following 5 kinds (default is geshu_strategy_period, the period is - minutes):

2. Note: The data escalation policy is recommended to be set when the app starts. The data escalation policy is set up and viewed using the following interfaces:

/**

Set escalation Policy

*/

@property (nonatomic,assign) Geshustatreportstrategytype reportstrategy;

3. escalation policy under WIFI environment

considering the The cost of reporting data in a WiFi network environment is small, so by default in a wifi Environment, a real-time escalation policy is used. To close the policy, you can call the following interface to close:

/**

Intelligent Escalation

device access after opening WIFI will be reported in real time

Otherwise, follow the global policy escalation

Open By default

*/

@property (nonatomic, assign) BOOL smartreporting;

4. Data escalation policy related interface

/**

The statistics escalation policy is BATCH , the minimum number of cached messages when the escalation is triggered, the default

*/

@property (nonatomic, assign) Nsuinteger Minbatchreportnumber;

/**

the escalation policy is PERIOD When sending interval, per minute, default day ( minutes)

*/

@property (nonatomic, assign) Nsuinteger periodminutes;

Eight, integration Application submission App Store considerations for SDK

1, in order to obtain accurate statistical results, you need to add adsupport.framework Library Support, so when you submit the App Store to do the following:

(1) in the App ads in the market, get IDFA can be audited by Apple.

(2)     There are no ads in the App, but a specific ad was previously placed, which can be checked by Apple for review.

Tick

The above is I integrated a push application statistics products (number) of the whole process, I hope to help you! If you have any other questions, we can message area Exchange.

Push data statistics products (number of) iOS integration practices

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.