# General

### Batch sample apps

If you want to see a proper integration of the Batch SDK and to test any of its functionalities, you can take a look at our **sample apps**.

→ [Download the sample app on GitHub](https://github.com/BatchLabs/batchcast-ios)

They are currently written for iOS in both Swift and Objective-C.

### Manual framework integration

{% stepper %}
{% step %}
**Step 1**

First, download the SDK and Include `Batch.xcframework` in your project by dragging and dropping it into the Project Navigator as shown here:

![Project Navigator view](/files/mudzJAkJVBNLHrEFCJb5)

Unless you manually copied the XCframework folder into your project's directory, check `Copy items if needed`. Make sure the only checked target is your Application target: extensions should be unchecked.

![Xcode add framework to project](/files/Ib04bVTbTS57ju21vq9H)
{% endstep %}

{% step %}
**Step 2**

Be sure `Batch.xcframework` and `libsqlite3.tbd` are in the **Build Phases** of your application target:

![Link with libraries build phase](/files/YtE0HdQ6SupCy8oTKWJ1)
{% endstep %}

{% step %}
**Step 3**

In order to avoid a link issue when building your application, add `-ObjC -lz` to **Other Linker Flags**, under **Build Settings** of your application target.

![Linker flags](/files/ix9sOMt4oXlDmf2HaFis)

{% hint style="info" %}
You can now proceed with the [integration of the SDK](/developer/sdk/ios/sdk-integration.md)
{% endhint %}
{% endstep %}
{% endstepper %}

### Generating the .p12 certificate

#### Creating a certificate

Batch servers need to have a certificate in order to communicate with Apple Push Notification Services *(APNS)*. This certificate is generated for an unique Application Identifier *(App ID)*.

{% stepper %}
{% step %}
**Step 1.**

Open your **Keychain application** on your Mac. In the menu bar, select **"Keychain Access" → "Certificate Assistant" → "Request a Certificate From a Certificate Authority…"**

![Keychain](/files/inEOAYAYcrasGegdyyKf)

Then, enter your information in the required fields and select **"Saved to disk"**. Save the *"CertificateSigningRequest.certSigningRequest"* file to your Desktop.

![Certificate](/files/87ZJhfutYI77clEFbGqP)
{% endstep %}

{% step %}
**Step 2.**

Head to the [Apple Developer Member center](https://developer.apple.com/account/resources/identifiers/list), open the `Identifiers` section and create a new App ID *(or choose an existing Explicit App ID)* to configure Push Notifications.

![Entitlements](/files/TG39tFLb7M0q1NkBzRZE)

Scroll down to the Push Notifications section, check it if needed and click configure.

![SSL certificate popup](/files/ZAvAEMbYwuxKN83SNcn6)

Under *"Production SSL Certificate"*, click on **"Create Certificate..."**. The Production certificate can push both sandbox and production environments.

The next screen will ask us to upload the Certificate Signing Request *(CSR)*, which we have created earlier.

![CSR Upload](/files/kBuLFlylNCg3DrqPXSMO)

Select **"Choose File…"** and locate the *.certSigningRequest* file on your desktop. Finally, select **"Continue"** and download the generated SSL certificate.

![Generated Certificate](/files/f8W4l6XGIZrmU8HBQxmv)
{% endstep %}
{% endstepper %}

#### Generating the .p12 file

Now you have the certificate, you need to have it with its key bundled into a .p12 file format.

{% stepper %}
{% step %}
**Step 1.**

First, add the certificate to your **Keychain** by double clicking on the downloaded SSL certificate.

In Keychain Access, pick the default keychain (`login` on English systems) using the sidebar. Then, click on **"My Certificates"** and find the certificate you just added. It should be called *"Apple Push Services:"*.

{% hint style="info" %}
Certificates called **"Apple Production IOS Push Services"** and **"Apple Development IOS Push Services"** are not supported anymore. Please generate a new Production Certificate
{% endhint %}
{% endstep %}

{% step %}
**Step 2.**

Make sure that the certificate is collapsed (the arrow on the left ( > ) should point to the right).\
Right-click on the certificate, select **"Export Apple Push Services:…"**, and save it as a .p12 file.

![Keychain export menu](/files/bpJF2W5dt8iHBckF77bH)

You will be prompted to enter a password which will be used to protect the exported certificate.

![Keychain export password prompt](/files/wSsaFbgR5rOyXnsYnJWh)

{% hint style="info" %}
If the Personal Information Exchange (.p12) option is grayed out in the export sheet, make sure *"My Certificates"* is selected in Keychain Access.
{% endhint %}
{% endstep %}

{% step %}
**Step 3.**

Now go to Batch's dashboard → ⚙ **Settings → Channel -> iOS**, and upload your P12 certificate.

![BatchSettings](/files/VPDvIMeDe0SGtMr8Czsg)

{% hint style="info" %}
**Troubleshooting: I**f you're having trouble uploading your certificate, you can check our [troubleshooting documentation](/developer/sdk/ios/troubleshooting.md).
{% endhint %}
{% endstep %}
{% endstepper %}

#### Generating your Provisioning Profile

After creating a new App ID or modifying your existing one, you need to (re)generate your provisioning profile and build with it.

{% stepper %}
{% step %}
**Step 1.**

Go to [Apple Developer website](https://developer.apple.com/account/ios/identifiers/bundle/bundleList.action), then click on **"Provisioning Profiles"** from the iOS Apps section.

Click on the **"+"** button to create a new iOS Provisioning Profile or select an existing one.

{% hint style="info" %}
If you already have one, make sure it has *Push Notifications* in the **Enabled Services** field.
{% endhint %}
{% endstep %}

{% step %}
**Step 2.**

In the Provisioning Profile creation wizard:

* **Select Type:** Choose *"App Store"*.
* **Configure:** Choose the App ID you created before from the drop down and make sure to select your iOS Production certificate.
* **Generate**: Choose a name for this provisioning profile, such as "Batch Push App Profile" and select *"Generate"*

Then download the generated provisioning profile from the next screen by selecting the **"Download"** button.
{% endstep %}

{% step %}
**Step 3.**

Install the profile by double-clicking on the downloaded file.

Your new provisioning profile should appear in the Provisioning Profiles section in your Xcode settings under the **"Accounts"** section. Make sure that your developer certificate is installed in your Keychain.

{% hint style="info" %}
Batch Push campaigns are sent to both the apps built with your **Development** and the **Distribution** provisioning profile.
{% endhint %}
{% endstep %}
{% endstepper %}

### Problems with your application delegate

If Batch tells you that it was unable to automatically integrate with your application delegate, it's probably because there is a conflict with another SDK.

Try calling `[BatchSDK startWithAPIKey:]` earlier in your application delegate.


---

# 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://doc.batch.com/developer/sdk/ios/advanced/general.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.
