# iOS

{% hint style="warning" %}
This document provides instructions on how to apply IMQA SDK in the React Native environment.
{% endhint %}

## 1. Common

### MPM Module install&#x20;

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

{% code title="When Using npm Command" %}

```
 npm install imqa-react-native-agent --save
 npx pod-install
```

{% endcode %}

{% code title="When Using yarn Command" %}

```
 yarn add imqa-react-native-agent
 npx pod-install
```

{% endcode %}

## 2. Setting a project&#x20;

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

{% code title="ImqaSettings.m" %}

```objectivec
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)
```

{% endcode %}

### Setting network collection&#x20;

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

{% code title="ImqaSettings.m" %}

```objectivec
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
```

{% endcode %}

### Checking collected data&#x20;

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

{% code title="ImqaSettings.m" %}

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

{% endcode %}

## 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**

```objectivec
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](/imqa-guide/eng/user-guide/using-mpm/project-list.md#proguard-dsym-settings).<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imqa.io/imqa-guide/eng/installation-guide/react-native/ios.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
