iOS

Install SDK in React Native Environment

This document provides instructions on how to apply IMQA SDK in the React Native environment.

1. Common

MPM Module install

To apply IMQA SDK in the React native environment, execute the command below to install the package.

When Using npm Command
 npm install imqa-react-native-agent --save
 npx pod-install
When Using yarn Command
 yarn add imqa-react-native-agent
 npx pod-install

2. Setting a project

1. Create the ImqaSettings.h file and enter the following:

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
@interface ImqaSetting : NSObject
- (void) IMQASetting;
@end
NS_ASSUME_NONNULL_END

2. Create the ImqaSettings.m file and enter the following:

#import "ImqaSetting.h"
#import <IMQAMPMAgent/IMQAMPMAgent.h>

@implementation ImqaSetting
- (void) IMQASetting{
  
  if (([NSUserDefaults.standardUserDefaults objectForKey:@"serverUrl"] == nil)) {
    [NSUserDefaults.standardUserDefaults setObject:@"https://collector.imqa.io" forKey: @"serverUrl"];
  }
  
  if (([NSUserDefaults.standardUserDefaults objectForKey:@"projectKey"] == nil)) {
    [NSUserDefaults.standardUserDefaults setObject:@"" forKey: @"projectKey"];
  }
  
  NSString* PROJECT_KEY = [NSUserDefaults.standardUserDefaults objectForKey:@"projectKey"];
  NSString* API_URL = [NSUserDefaults.standardUserDefaults objectForKey:@"serverUrl"];
  NSLog(@"[IMQA] setAgentConfig : %@ %@", PROJECT_KEY, API_URL);
  IMQAConfig* mpmConfig = [[IMQAConfig alloc] init:PROJECT_KEY];
  mpmConfig.api_url = API_URL;
  [[IMQAMpm sharedInstance] runWithConfig:mpmConfig];
}
@end

3. Import the one below from the AppDelegate.h file.

#import "ImqaSetting.h"

4. In the AppDelegate.m file, add the code below to the top of - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions.

ImqaSetting* is = [ImqaSetting new];
[is IMQASetting];

3. Detailed setting

The iOS MPM framework supports various settings.

Setting the collection interval

You can set the interval for the IMQA MPM framework to save and collect data in seconds.

  • Objective-C

ImqaSettings.m
IMQAConfig* mpmConfig = [[IMQAConfig alloc] init:@"PROJECT_KEY"];
mpmConfig.dump_interval = 10; // Interval of getting the performance data dump (sec)
mpmConfig.save_interval = 60; // Interval of sending performance data to the collection server (sec)

Setting network collection

The IMQA MPM framework can set whether or not to collect network information. The framework also provides a function that can ignore the collection of a specific URL, which enables you to ignore the URL that requires security.

  • Objective-C

ImqaSettings.m
IMQAConfig* mpmConfig = [[IMQAConfig alloc] init:@"PROJECT_KEY"];
mpmConfig.useNetworkCollect = YES; //YES: Collect, NO: Do not collect
mpmConfig.ignoreUrl = @[@"https://url1.com", @"http://url.com"]; // An array of specific URLs to ignore

Checking collected data

If you want to check the data collected by the IMQA MPM framework, you can check the data on the console using its own options.

  • Objective-C

ImqaSettings.m
IMQAConfig* mpmConfig = [[IMQAConfig alloc] init:@"PROJECT_KEY"];
mpmConfig.downloadDumpData = YES;

4. Network Collection (NSURLSession or URLSession)

When using NSURLSession or URLSession to communicate over the network, some settings are required for network collection.

  • Objective-C

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration]; // or default
configuration.protocolClasses = [[IMQAMpm sharedInstance] imqaURLSessionProtocol];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];

5. dSYM Settings

For apps with iOS Symbolication, you can view class names and function names through dSYM settings. See Using MPM > Project list > Project Management > ProGuard / dSYM settings.

Last updated