iOS | Quickly integrate AGC crash service with zero code

The operation of integrating the AGC crash service on the Android platform has already been introduced . This time, the IOS integration method is introduced. The operation is basically similar.

Create projects and applications

First, you need to create a project in AGC, add an application to the project, the operation is very simple, directly refer to the chapters on creating projects and applications in " Getting Started with IOS ".

Open Huawei analysis service

Since the crash service uses the capabilities of Huawei analysis services when reporting crash events, it is necessary to activate Huawei analysis services before integrating the Crash SDK . For details, please refer to “ Activating Huawei Analysis” .

Integrated SDK

For the Xcode development environment, the Crash SDK can be integrated into the Xcode development environment through the Cocoapods integration method before development.

  1. Log in to the AppGallery Connect website and click "My Project".
  2. Find the project you just created in the project list, and select the application to be integrated in the application list under the project.
  3. Click "agconnect-services.json" under "Application" in "Project Settings" to download the configuration file.

Insert picture description here

  1. Copy the "agconnect-services.plist" file to the Xcode project directory.

Insert picture description here

  1. Create a Podfile file.

Open a command line window, navigate to the location of the Xcode project, and create a Podfile. If it already exists, you can skip this step.

cd project-directory
 pod init
  1. Edit the Podfile file.
  • Integrate Analytics Kit and Crash SDK

Edit the Podfile file and add the pod dependency pod'HiAnalytics' and pod'AGConnectCrash'.

  target 'demo' do
   #   Pods for demo
    pod   'HiAnalytics'
    pod   'AGConnectCrash'
   end
 end
  • Install the pod, and then open the .xcworkspace file to view the project.
pod install
  1. Initialize AGConnectCore SDK and Analytics SDK.

Import the header file and add initialization code in the AppDelegate.m file of the project.

 #import   "AppDelegate.h"
 #import   <AGConnectCore/AGConnectCore.h>
 #import   <HiAnalytics/HiAnalytics.h>
 @implementation   AppDelegate
 -   (BOOL)Application:(UIApplication *)Application   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      // Override point for customization   after Application launch.
      [AGCInstance startup];//初始化
      [HiAnalytics config];//初始化
      return YES;
 }
 ...
 @end

Crash test

In order to test the crash, directly set a button "makecrash" in the demo, and click the button to trigger the crash. IOS button creation is very simple, just drag and drop, the effect is as follows:

Insert picture description here

Call the AGC built-in testIt method to trigger a crash, the effect is as follows:

Insert picture description here

Use the Xcode simulator, run the program to install the application, open the application and click "makecrash" to cause a crash.

Crash report view

  1. Log in to the AppGallery Connect website and click on the "My Project" icon to enter the application that triggered the crash.

  2. On the crash service page, click the "Statistics" tab, the default display is "Last 24 hours". You can see that the crash information has been reported (see it in 1-2 minutes).

Insert picture description here

  1. Click the "Problems" tab to view the crash problem, and it shows that "NSRangeException" is indeed a manual crash.

Insert picture description here

Continue to click on the crash problem to view the details, you can see the detailed cause of the crash problem.

Insert picture description here

to sum up:

  1. The integrated crash service is very simple. You can write your own code during testing, or you can use the testIt method that comes with AGC.

  2. The crash report is displayed very quickly, usually within 1-2 minutes.

  3. In addition to writing a few lines of code for testing, the application is officially launched, as long as the SDK is integrated, which is truly zero code.

  4. The crash service also provides functions such as obfuscated report restoration and custom reports.

Reference documents:

Huawei AGC crash service development document:https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-crash-introduction

Android | Quickly integrate AGC crash service with zero code:

https://developer.huawei.com/consumer/cn/forum/topic/0201387764119030047?fid=0101271690375130218


Original link:
https://developer.huawei.com/consumer/cn/forum/topic/0201393538013250134?fid=0101271690375130218
Author: Drum Chao

Guess you like

Origin blog.51cto.com/14772288/2547119