Push data statistics products (number of) iOS integration practices

Source: Internet
Author: User

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 the message push) of the new product "Number of application statistics", according to the official statement, a push 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 and so on. 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 to get app ID

1, visit a Push developer center, 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, back to the push developer Center use the last step registered account login, enter the developer platform Panel, select the number of left menu bar • 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).

Three, Cocoapods integration mode

1, installation Cocoapods

The installation is simple, with Ruby under your Mac, and you can download the installation using Ruby's GEM command:

$ sudo gem install Cocoapods
$ pod Setup


2, Prepare Podfile

You need to create a new file named Podfile (if the file already exists, you do not need to recreate it), in the following format, the dependent library name is listed in the file:

Target ' yourtargetname ' do
Platform:ios, "8.0"
Pod ' GCSDK '
End

3. Complete GCSDK Import

Place the edited Podfile file in your project's root directory and execute the following command:

$ CD "<path/to/project>"
$ pod Install

4, after using the Cocospods Integration SDK, you need to close the original project, re-open the Yourprojectname.xcworkspace file under the project root directory for subsequent development:

Four, Xcode integration mode

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, select number · iOS-side Download SDK Resource pack for 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, supported iOS versions 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

Locate the main project target, Build Setting, linking, and other Linker Flags, set it to-OBJC ():

V. Initialize and launch the SDK

1. Initialize the relevant information of the starting interface:


2. Add a header file to the project's APPDELEGATE.M, initialize and launch the SDK using 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"), which uniquely identifies an event by event_id and properties.

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 60 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

Given the low cost of reporting data in a WiFi network environment, the default is to use a real-time escalation policy in a WiFi environment. To close the policy, you can call the following interface to close:

/*
Intelligent escalation
Device Access WiFi will be reported in real time after opening
Otherwise, follow the global policy escalation
Open by default
/
@property (nonatomic, assign) BOOL smartreporting;

4. Data escalation policy related interface

/*
When the statistics escalation policy is BATCH, the minimum number of cached messages when the escalation is triggered, the default 32 bar
/
@property (nonatomic, assign) Nsuinteger Minbatchreportnumber;

/*
Send interval when escalation policy is PERIOD, per minute, default day (60 minutes)
/
@property (nonatomic, assign) Nsuinteger periodminutes;

VIII. Application Submission App Store considerations for integrated 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) Advertise in app, get IDFA to be approved 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.

Check

![](http://i2.51cto.com/images/blog/201807/27/6325bcc339f07bb78366f659af0bee84.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

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

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.