> For the complete documentation index, see [llms.txt](https://docs.sportradar.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sportradar.com/ufc-5.0/sdk-integration/ios-sdk.md).

# iOS SDK

MGA SDK for iOS is library for iOS providing a powerful high-level webview abstractions to interact with the IMGA web app.

### Installation

IMGA SDK supports multiple methods for installing the library in a project.

### Installation with CocoaPods

To integrate IMGA SDK into your Xcode project using CocoaPods, specify it in your `Podfile`:

```
pod 'IMGASDK', :git => 'git@github.com:IMGARENA/front-row-seat-ios-cocoapod.git', :tag => 'v0.12'
```

### Installation with SPM

To integrate IMGA SDK into your Swift project using SPM, specify it in your Package.swift

```
dependencies: [
    .package(url: "https://github.com/IMGARENA/front-row-seat-ios-cocoapod", from: "0.12.0")
],
```

### Requirements

IMGA SDK requires iOS 14 and xCode 14.1

### Usage

**Creating an instance**

```
 let imga = IMGASDK(logLevel: .debug)
```

#### Initialiasing de SDK (launch)

**Launching the SDK with raw data**

```
let eventCentreData:IMGAData = [
            "operator": "[OPERATOR-NAME]",
            "sport": "ufc",
            "targetModule": "full",
            "eventId": "667",
            "language": "en",
            "version": "5.x",
            "targetElementSelector": "#img-arena-event-centre",
            "options":["videoPlaybackEnabled": "true"]
        ]
//Launch with the event centre data
try? imga.launch(with: eventCentreData) { imgaView in
    if let newView = imgaView {
        //Do something with the imgaView
    }
}
```

**Launching the SDK with IMGAEventCentreParams object**

```
let initialContex:IMGAData = [
          view: "Fight",
          fightId: "fightID"]
        
let eventCentreDataParams = IMGAEventCentreParams(operatorName: "operatorName",
                                         sport: "sport",
                                         version: "version",
                                         eventId: "eventId",
                                         language: "language",
                                         theme: "theme",
                                         targetModule: "targetModule",
                                         initialContext: initialContex,
                                         options: nil,
                                         targetElementSelector: "targetElementSelector")

//Launch with the event centre data
try? imga.launch(with: eventCentreDataParams) { imgaView in
    if let newView = imgaView {
        //Do something with the imgaView
    }
}
```

**Launching the SDK and append the IMGA View to a container**

```
let initialContex:IMGAData = [
view: "Fight",
fightId: "fightID"]

let eventCentreDataParams = IMGAEventCentreParams(operatorName: "operatorName",
                        sport: "sport",
                        version: "version",
                        eventId: "eventId",
                        language: "language",
                        theme: "theme",
                        targetModule: "targetModule",
                        initialContext: initialContex,
                        options: nil,
                        targetElementSelector: "targetElementSelector")

//Container where to add the IMGA view
let myContainer = UIView()

//Launch with the event centre data
try? imga.launch(andAddTo: myContainer, with: eventTest1)
```

**Subscribing to status changes**

```
//Instance the sdk
let imga = IMGASDK(logLevel: .debug)
//Subscribe to the sdk status changes
imga.onStatusChange = {status, error in
    print("Status:\(status)")
    if let e = error {
        print("Error on status:\(e)")
    }
}
```

**Subscribing to new messages**

There are several types of messages/topics

* `CONTEXT_UPDATE`: Topic for covering general UI state updates, for example navigation changes or the user selecting a player in the UI.
* `HANDSHAKE_FAILED`: Topic to signify the handshake between Event Centre and your site failed to complete.

```
//Instance the sdk
let imga = IMGASDK(logLevel: .debug)
imga.onNewMessage = {name, message, error in
    print("New Message:\(name)-\(message)")
    if let e = error {
        print("Error on message:\(e.description)")
    }
}
```

**Stop the sdk**

```
//Instance the sdk
let imga = IMGASDK(logLevel: .debug)
//Stop the instance
imga.stop()
```

### Video Streaming Authentication

Please reference the doc here.

### Credits

IMGA SDK is owned and maintained by the IMGA Development team.

### License

IMG Media Limited


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sportradar.com/ufc-5.0/sdk-integration/ios-sdk.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
