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

# Platform-Specific Setup

> iOS and Android native setup for the Zixflow React Native SDK.

### iOS Setup

#### CocoaPods Integration

The Zixflow React Native SDK integrates with the native iOS SDK via CocoaPods. If you're using **React Native 0.60 or higher**, core dependencies are auto-linked.

1. **Navigate to the iOS directory**:

```bash theme={null}
cd ios
```

2. **Install CocoaPods dependencies**:

```bash theme={null}
pod install
```

3. **Open the workspace in Xcode**:

```bash theme={null}
open YourApp.xcworkspace
```

For most React Native apps, CocoaPods auto-linking is enough for CDP. **Push requires an explicit Podfile subspec** (next section).

#### Push Notification Setup (APNs)

1. **Add the APNs subspec** in your `ios/Podfile` (inside your app target), then run `pod install`:

```ruby theme={null}
pod 'zixflow-reactnative/apn', :path => '../node_modules/zixflow-reactnative'
```

For Firebase on iOS instead, use `zixflow-reactnative/fcm` and `use_frameworks! :linkage => :static` — see [Push Notifications](/documentation/sdk/react-native/push-notifications).

2. **Enable Push Notifications** in Xcode:
   * Select your app target → **Signing & Capabilities**
   * Click **+ Capability** → **Push Notifications**

3. **Enable Background Modes**:
   * Add **Background Modes**
   * Enable **Remote notifications**

4. **Configure AppDelegate** — call `FirebaseApp.configure()` (FCM path) and register the `ZX_2BTN` category for action buttons. Full pattern: [Push Notifications](/documentation/sdk/react-native/push-notifications) and the [example AppDelegate](https://github.com/zixflow/sdk-examples/blob/main/react-native/ios/ZixflowRNDemo/AppDelegate.swift). Receive/display/tracking run in JS via Firebase Messaging + notifee.

5. **Upload APNs credentials** in the Zixflow dashboard.

#### Notification Service Extension (rich push)

To support **rich push** (images) and reliable **delivery** tracking on iOS, add a Notification Service Extension:

1. **File > New > Target > Notification Service Extension** (e.g. `NotificationServiceExtension`)

2. **Add the rich-push pod** for APNs:

```ruby theme={null}
target 'NotificationServiceExtension' do
  pod 'zixflow-reactnative-richpush/apn', :path => '../node_modules/zixflow-reactnative'
end
```

For FCM: `zixflow-reactnative-richpush/fcm`.

3. **Update `NotificationService.swift`** (canonical snippet — same as the push guide):

```swift theme={null}
import UserNotifications
import ZixflowMessagingPushAPN

class NotificationService: UNNotificationServiceExtension {
  var contentHandler: ((UNNotificationContent) -> Void)?
  var bestAttemptContent: UNMutableNotificationContent?

  override func didReceive(
    _ request: UNNotificationRequest,
    withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
  ) {
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

    MessagingPushAPN.initializeForExtension(
      withConfig: MessagingPushConfigBuilder(apiKey: "YOUR_API_KEY")
        .appGroupId("group.com.yourcompany.yourapp.zixflow")
        .build()
    )
    MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
  }

  override func serviceExtensionTimeWillExpire() {
    MessagingPush.shared.serviceExtensionTimeWillExpire()
  }
}
```

4. Run `pod install` again.

5. Add matching [App Groups](/documentation/sdk/react-native/push-notifications#app-groups) on the host app and NSE, and pass the same `.appGroupId(...)` from `AppDelegate` push init.

#### Location module (optional)

```ruby theme={null}
pod 'zixflow-reactnative/location', :path => '../node_modules/zixflow-reactnative'
```

See [Location Tracking](/documentation/sdk/react-native/location-tracking).

***

### Android Setup

#### Gradle Configuration

The React Native auto-linking will handle most of the Android setup. However, you need to ensure the following:

1. **Set minimum SDK version** in `android/build.gradle`:

```gradle theme={null}
buildscript {
    ext {
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
    }
}
```

2. **Add Maven repositories** in `android/build.gradle`:

```gradle theme={null}
allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
    }
}
```

The Zixflow Android SDK will be automatically included via the React Native module.

#### Firebase Cloud Messaging Setup

To enable **Firebase Cloud Messaging (FCM)** for push notifications on Android:

1. **Add Firebase to your project**:

   * Go to [Firebase Console](https://console.firebase.google.com/)

   * Add your Android app (package name must match `applicationId` in `android/app/build.gradle`)

   * Download the **client** `google-services.json` and place it in `android/app/`

   > Use the Firebase **client** config (`project_info` + `client` array). Do **not** put a Firebase service-account JSON in the app.

2. **Add Google Services plugin** in `android/build.gradle`:

```gradle theme={null}
buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.4.2'
    }
}
```

3. **Apply the plugin** in `android/app/build.gradle`:

```gradle theme={null}
apply plugin: 'com.google.gms.google-services'
```

4. **Configure push in `Zixflow.initialize`** (Android push module registers from JS init — unlike iOS, you do not initialize push in native `Application` code for the recommended path):

```typescript theme={null}
import {
  Zixflow,
  ZixflowConfig,
  ZixflowLogLevel,
  PushClickBehaviorAndroid,
} from 'zixflow-reactnative';

const config: ZixflowConfig = {
  apiKey: 'YOUR_API_KEY',
  logLevel: ZixflowLogLevel.Debug,
  autoTrackDeviceAttributes: true,
  trackApplicationLifecycleEvents: true,
  push: {
    android: {
      pushClickBehavior: PushClickBehaviorAndroid.ActivityPreventRestart,
    },
  },
};

await Zixflow.initialize(config);
```

5. **Request permission and identify** (see [Push Notifications](/documentation/sdk/react-native/push-notifications)):

```typescript theme={null}
await Zixflow.identify({ userId: 'user-123', traits: { email: 'user@example.com' } });
await Zixflow.pushMessaging.showPromptForPushNotifications();
const token = await Zixflow.pushMessaging.getRegisteredDeviceToken();
```

#### Permissions

Ensure `POST_NOTIFICATIONS` is available for Android 13+ (the SDK module declares it; your app still prompts at runtime via `showPromptForPushNotifications`).

***

### Next steps

* Full push guide: [Push Notifications](/documentation/sdk/react-native/push-notifications)
* Metrics: [Push Notification Tracking](/documentation/sdk/react-native/push-notification-tracking)
* Continue with [Quick Start](/documentation/sdk/react-native/quick-start)
