# Getting Started

The **Referd** SDK for iOS enables you to use the show **Referd** user profile in your app, track app user events, integrate referrals and display **Referd's** in-app push notifications.

## Installation

Follow the below steps to start installing the iOS SDK to your app

#### **1. Add Cocoapods to Your Project**

{% hint style="info" %}
If your project is using CocoaPods, skip to the next part of this article, [Add Referd Pod](#id-2.-add-referd-pod).
{% endhint %}

* Open the terminal window
* Navigate to the root folder of your Xcode project
* Run the following command in terminal

```objectivec
$ pod init
```

* Close Xcode if open then open your project’s newly created .xcworkspace
* Your project is now using CocoaPods to install dependencies

#### **2. Add Referd Pod**

* Add the code below in your Podfile which was created by CocoaPods

```ruby
source 'https://github.com/CocoaPods/Specs.git'
target 'YourAppName' do
           use_frameworks!
           pod 'Gameball',
End
```

* Navigate to your project’s root folder in a terminal window
* Run the command below in terminal

```objectivec
$ pod install
```

* Referd will install several Pods that it has as dependencies.

{% hint style="success" %}
When the Pod command finishes execution, you will have Referd installed and ready to use.
{% endhint %}

{% hint style="info" %}
Referd is also available through **\[Swift Package Manager]**. To install it, simply search for 'Referd' or add the repo URL:

```
https://github.com/gameballers/gameball-ios.git
```

{% endhint %}

## Initialization

Import the SDK into the created pod, using CocoaPods, to setup the **Referd** Widget in the best way for your use-case.

In order to use Referd you must configure a GameballApp.

* Import our pod to your viewController

```objectivec
import Gameball
```

* Create a global GameballApp variable in your viewController to access anywhere within your viewController

```swift
var gameball: Gameball?
```

* Then initialize it as the following:

```swift
gameball = Gameball(
    apiKey: "YOUR_API_KEY", // The only required field
    lang: "ar",
    shop: "MyShop",
    platform: "iOS",
    completion: { [weak self] in // Completion block when SDK init is completed
        guard let self = self else {return}
        // You can enable showing profile, registering player, etc. see next section
    }
)
```

## &#x20;<a href="#user-registration" id="user-registration"></a>

| Parameter    | Required | Description                                                                                                                                                                                                                                                                                                                                                 |
| ------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey`     | Required | Client API key                                                                                                                                                                                                                                                                                                                                              |
| `lang`       | Optional | <p>Your platform language preference to view <strong>Referd</strong> Widget with. <strong>Note:</strong> The language provided should be as per configured languages in your account. If not provided the Referd profile widget will be shown with your account default language.</p><p><strong>Example:</strong> <code>"en"</code>, <code>"fr"</code>.</p> |
| `completion` | Optional | Completion block that gets called when the initialization of the SDK is completed                                                                                                                                                                                                                                                                           |

{% hint style="info" %}
You may also check the sample project [here](https://github.com/gameballers/gameball-ios/tree/master/Example) to view full implementation.
{% endhint %}
