- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize HUAWEI Analytics.
[HiAnalytics config];
return YES;
}
Skip this step if you use the visual event function to add events.
// Customize an event to report.
// Set the custom event name to Purchase.
// Set customKey and customValue to specify a custom event key and value, respectively.
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
// Customize parameters.
[params setObject:@"9.99" forKey:@"price"];
[params setObject:@"100L" forKey:@"quantity"];
[params setObject:@"CNY" forKey:@"currency"];
// Report the event.
if (self.customKey.text.length >0 && self.customValue.text.length >0) { [1]
[params setObject:self.customValue.text forKey:self.customKey.text];
}
[HiAnalytics onEvent:self.eventName.text setParams:params]; The following figure shows the demo app screen in the codelab.

During development, you can enable the debug mode to view the event records in real time, observe the results, and adjust the event tracking scheme as needed.
Enabling the debug mode: Select Arguments in Edit scheme, and add -HADebugEnabled.
Disabling the debug mode: Select Arguments in Edit scheme, and delete -HADebugEnabled.
Enabling the debug mode: Select Arguments in Edit scheme, and add -FIRAnalyticsDebugEnabled and -FIRDebugEnabled.
Disabling the debug mode: Select Arguments in Edit scheme, and delete -FIRAnalyticsDebugEnabled and -FIRDebugEnabled.
Enabling the debug mode: Select Arguments in Edit scheme, and add -DTMDebugEnable and -DTMLogLevelDebug.
Disabling the debug mode: Select Arguments in Edit scheme, and delete -DTMDebugEnable and -DTMLogLevelDebug.
For details about debugging operations in AppGallery Connect, please refer to App Debugging.
After the debug mode is enabled, all events will be reported in real time.

Successfully reported data is displayed on HUAWEI Analytics in real time, as shown in the screenshots below.


