> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appcharge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Initialize the SDK

This article explains how to configure and initialize and configure the Payment Links SDK for iOS.

## Configure the SDK

The Payment Links SDK for iOS exposes a `ACConfigModel`. Create an instance with the following arguments:

```swift Swift theme={"system"}
let config = ConfigModel(
    checkoutPublicKey: "{YOUR_CHECKOUT_PUBLIC_KEY}",
    environment: "sandbox",
    redirectUrl: "https://your-universal-link-redirect-url.com"
)
```

```c Objective-C theme={"system"}
ACConfigModel *config = [[ACConfigModel alloc] initWithCheckoutPublicKey:@"{YOUR_CHECKOUT_PUBLIC_KEY}" environment:@"sandbox" redirectUrl:@"https://your-universal-link-redirect-url.com"]; 
```

| Argument | Type | Required? | Description |
| - | - | - | - |
| `checkoutPublicKey` | `string` | Yes | The checkout public key, located in the Publisher Dashboard. In the sidebar menu, click **Settings**, then select the **Integration** tab. Copy the **Checkout Public Key** value. |
| `environment` | `string` | Yes | The checkout environment. One of: - `sandbox`: For testing. - `production`: For live operations. |
| `redirectUrl` | `string` | For external browser only | The URL to redirect the player back to your game after checkout. Set the value to `https://{YOUR_ASSOCIATED_DOMAIN_VALUE}.`. |

## Initialize the SDK

To initialize the SDK, call the method below using the `ACConfigModel`. We recommend doing this on application load, ideally within the `viewDidLoad` lifecycle method:

```swift Swift theme={"system"}
import ACPaymentLinks
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        let config = ACConfigModel(
            checkoutPublicKey: "{YOUR_CHECKOUT_PUBLIC_KEY}",
            environment: "sandbox",
            redirectUrl: "https://your-universal-link-redirect-url.com"
        )
        // Initialize the SDK with the delegate
        ACBridgeAPI.initialize(configModel: config, delegate: self)
    }
}
```

```c Objective-C theme={"system"}
#import <ACPaymentLinks/ACPaymentLinks.h>
#import <ACPaymentLinks/ACPaymentLinks-Swift.h>

@interface ViewController : UIViewController <ACBridgeAPIDelegate>
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    ACConfigModel *config = [[ACConfigModel alloc] initWithCheckoutPublicKey:@"{YOUR_CHECKOUT_PUBLIC_KEY}" 
                                                                 environment:@"sandbox" 
                                                                 redirectUrl:@"https://your-universal-link-redirect-url.com"];
    // Initialize the SDK
    [ACBridgeAPI initializeWithConfigModel:config delegate:self];
}

@end
```

## Re-initialize the SDK

Re-initialize the SDK when you change between `sandbox` and `production` environments:

```swift Swift theme={"system"}
ACBridgeAPI.initialize(configModel: config, delegate: self)
```

```c Objective-C theme={"system"}
[ACBridgeAPI initializeWithConfigModel:config delegate:self];
```

## Lock checkout orientation

You can force the Checkout page to display in portrait orientation, even if the app is currently in landscape mode.

```swift Swift theme={"system"}
// Checkout opens using the app’s current orientation (default)
ACBridgeAPI.portraitOrientationLock = false 

// Checkout is locked to portrait orientation
ACBridgeAPI.portraitOrientationLock = true
```

```c Objective-C theme={"system"}
// Checkout opens using the app’s current orientation (default)
[ACBridgeAPI setPortraitOrientationLock:@0];

// Checkout is locked to portrait orientation.
[ACBridgeAPI setPortraitOrientationLock:@1];
```

## Enable debug mode

Enable debug mode to view detailed logs from all parts of the SDK. This provides deeper visibility into the SDK’s behavior:

```swift Swift theme={"system"}
ACBridgeAPI.setDebugMode = true
```

```c Objective-C theme={"system"}
[ACBridgeAPI setSetDebugMode:@YES];
```
