# Getting Started

### 1. Install the SDK

#### Cocoapods

The easiest way to use Antsomi in your iOS project is with [CocoaPods](https://cocoapods.org/pods/WebEngage). Before you begin, please ensure that you are using [Ruby v2.0.0](https://www.ruby-lang.org/en/installation/) or higher (knowledge of Ruby syntax isn’t needed to install the SDK).

**Step 1: Download CocoaPods**

CocoaPods is a dependency manager for Swift and Objective-C projects. You can install CocoaPods by running the following command.

{% tabs %}
{% tab title="Shell" %}

```sh
$ sudo gem install cocoapods
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Please refer to the [CocoaPods Troubleshooting Guide](http://guides.cocoapods.org/using/troubleshooting.html) in case you have trouble using CocoaPods.
{% endhint %}

**Step 2: Add a** `Podfile`

In the terminal, navigate to your Xcode project directory and create a `Podfile` by running the following command.

{% tabs %}
{% tab title="Shell" %}

```sh
$ pod init
```

{% endtab %}
{% endtabs %}

**Step 3: Edit your** `Podfile`

Add the following in your `Podfile` under your project's target.

{% tabs %}
{% tab title="Ruby" %}

```ruby
# Avoid use_frameworks! declaration in your Podfile.

target 'YourAppTarget' do
  pod 'AntsomiFramework', '1.1.59'
end
```

{% endtab %}
{% endtabs %}

**Step 4: Install AntsomiFramework SDK**

To install the Antsomi SDK, navigate to your Xcode project directory and run the following command.

{% tabs %}
{% tab title="Shell" %}

```sh
$ pod install
```

{% endtab %}
{% endtabs %}

**Step 5:** Stop using your project file, `YOUR-PROJECT-NAME.xcodeproj`. And start using the project workspace file created by CocoaPods, `YOUR-PROJECT-NAME.xcworkspace` from now on.

* Doing so will ensure that the AntsomiFramework SDK is properly loaded.

### 2. Initialize the SDK

**Step 1:** Add `Antsomi.Configuration` to the `application:didFinishLaunchingWithOptions:` of your `AppDelegate`.

* We recommend that you make this call at the end of `didFinishLaunchingWithOptions:`.

**Step 2:** Add `registerForNotification` to the `application:didRegisterForRemoteNotificationsWithDeviceToken:` of your `AppDelegate`.

{% tabs %}
{% tab title="Swift" %}

```swift
import AntsomiFramework

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
  
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
                
        /**
          YOUR CODE GOES HERE
        **/
                
        let config = Antsomi.Configuration(portalId: "XXXXXXXXX", propsId: "YYYYYYYYY", appGroupId: "group.antsomi.news",applicationId: "b25d06f4-d322-46d5-b323-ZZZZZZZZZZZZ")        
        Antsomi.shared.activate(with: config)
        
        Antsomi.shared.trackAppLaunch()
        
        return true
  }

  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {        
        Antsomi.shared.registerForNotification(deviceToken)
  }
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
#import <AntsomiFramework/AntsomiFramework-Swift.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  
  /**
    YOUR CODE GOES HERE
  **/
  
  return YES;
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    Antsomi const *antsomi = [Antsomi shared];
    
    [antsomi registerForNotification: deviceToken];
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
If you haven't had your CDP365 Application ID, please follow this [instruction](https://docs.antsomi.com/cdp-365-user-guide-en/marketing-hub/destinations/all-destinations/app-notification#1.-antsomi-app-notification).
{% endhint %}

***

You have successfully integrated the Antsomi SDK with your iOS app and are sending user session and system events data to your Antsomi account. Please note that it may take a up to few minutes for your data to reflect on your dashboard.


---

# 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.antsomi.com/developers-guide/ios/getting-started.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.
