How Can I Integrate Crash of AppGallery Connect in React Native?

Search This thread

Mayism

Senior Member
Nov 5, 2020
101
25
github.com
HUAWEI AppGallery Connect Crash supports multiple platforms. Here’s how you can integrate the AppGallery Connect React Native plug-in. If you want to experience the remote configuration function, see the GitHub demo.

Integration Procedure
1. Install the React Native dependency.

npm install -g yarn
0*4S9BS1enIDi_lp0s.png

2. Create a project and enable Remote Configuration.

a) In AppGallery Connect, create an Android app, add the app to a project, and enable Crash and HUAWEI Analytics for it.

0*15qbS54OEl60aA5a.png

b) Run the following command to create a React Native project. In this example, name the project rncrashdemo.

npx react-native init rncrashdemo
0*v73YqLFM_db0n_Mf.png

c) Add the configuration file to your React Native project.

Add the agconnect-services.json file to the android/app directory of the React Native project.

0*C5mG9ktpdJz-CKD-.png

d) Configure the Maven repository address and AppGallery Connect plug-in address.

1) Open the build.gradle file in the android directory of your React Native project.
Go to allprojects > repositories and configure the Maven repository address.
Go to buildscript > repositories and configure the Maven repository address.
Go to buildscript > dependencies and configure the AppGallery Connect plug-in address.
0*H9Ly7uKR1myqflPe.png

2) Add build dependencies and the AppGallery Connect plug-in address.

Open the build.gradle file in the android/app directory of the React Native project and add the plug-in address.

0*i-l88mckb6r3dFjS.png

3. Install the plug-in.

In the project directory, run the following command to install the Crash plug-in.
npm install @react-native-agconnect/crash
0*xcrzAqn3XOfn8Rvw.png

4. Test the Crash service.

You can set a button to determine whether to report crashes. Create another button for testing. Click the button, call setUserId to set a custom user ID, call setCustomKey to set a custom key-value pair, call LogLevel to customize the log level, and call testIt to trigger a crash.

0*xnvH2d4qOcvBcRBJ.png

5. Install an app.
Run the yarn android command to install your app.
0*rRyM3QKdXzf0-WWU.png
Viewing a Crash Report
After integration, click the test button to trigger a crash and generate a custom crash report. You can view the report in AppGallery Connect.

1. Select Last hour.
0*YkQQsAYmNNecFjSK.png

2. View details about crash stack information.
0*VCYQhJv1khnBOqeb.png

3. View custom key-value pairs.
0*viefayix7tpyBUN0.png

4. View custom log levels.
0*irq667kmbnhjvhFg.png

5. View custom user IDs.
0*sE2XNVWg7kEmyzav.png
Reference
1. HUAWEI AppGallery Connect Crash documentation: https://developer.huawei.com/consum...Gallery-connect-Guides/agc-crash-introduction
2. HUAWEI AppGallery Connect Crash demo: https://github.com/AppGalleryConnect/agc-reactnative-plugin/tree/master/agc-crash-reactnative
 
Last edited: