Platform
Platform OverviewEmail MarketingSMS MarketingWhatsAppPush NotificationsRCS MessagingAI CampaignsAnalyticsAutomationCustomer Data Platform
Solutions
SolopreneursGrowing TeamsEnterpriseE-CommerceSaaSConsumer AppsMarketplaces
More
PricingBlogLaunch PlaybookCompany
Get StartedLog in

Developer Documentation

Complete integration guides for iOS and Android SDKs to get you started quickly.

iOS

PolarGX iOS SDK Installation Guide

A complete guide for integrating PolarGX SDK into your Swift or Objective‑C iOS app.

1. Create Polar project:

Create and configure Polar project in PolarGX Admin Portal

  • Register your PolarGX account at https://app.polargx.com.
  • Create your project.
  • Setting your project in Project Settings
  • Manage your API Keys in API Keys Configuration
  • Configure your link domain in Link Configuration > Required Redirects section > iOS Redirects with:
    • App Store Search / AppStore Id or Custom URL: Help your link redirects to AppStore or your custom url if your app hasn't been installed.
    • Universal Links: Help your link opens app immediately if your app was installed.
      • Open https://developer.apple.com. Locate your app identifier in Certificates, Identifiers & Profiles > Identifiers
      • Use App ID Prefix for Apple App Prefix
      • Use Bundle ID for Bundle Identifiers
    • Scheme URI (deprecated way): Help your link opens app if your app was installed and can't be opened by Universal Links. Example: yourapp_schemeurl://

2. Configure Xcode project

Configure Associated Domains:

  • In Xcode, open target settings. In Signing & Capabilities tab, enable Associated Domains capability.

  • In Associated Domains, add your link domain in Create Polar project step into Domains section with the following format:

    applinks:{subdomain}.gxlnk.com
    

Configure URL Scheme:

  • In Xcode, open target settings. In Info tab, scroll to URL Types section.
  • In URL Types, add a URL Type with URL Schemes set to the Scheme URL in Create Polar project step. Example: yourapp_schemeurl

3. Add PolarGX SDK

Install via Swift Package Manager (SPM)

PolarGX Swift SDK is available via Swift Package Manager (SPM).

  1. Open your project in Xcode.
  2. Go to File > Add Packages…
  3. Enter the package URL:
https://github.com/polargx/polargx-swift-sdk.git
  1. Set Dependency Rule to Up to Next Major Version (Recommended).
  2. Click Add Package.

4. Using PolarGX SDK

Using the SDK in Swift

In AppDelegate.swift

// Add: Import PolarGX
import PolarGX

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Your existing code

    // Add: Initialize Polar app
    PolarApp.initialize(appId: YOUR_APP_ID, apiKey: YOUR_API_KEY) { link, data, error in
        print("\n[POLAR] detect link clicked: \(link), data: \(data), error: \(error)\n")
        // Handle link clicked. This callback will be called in the main queue.
    }

    return true
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    // Add: Polar app handles the user activity
    return PolarApp.shared.continueUserActivity(userActivity)
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    // Add: Polar app handles the opening url
    return PolarApp.shared.openUrl(url)
}

In SceneDelegate.swift

// Add: Import PolarGX
import PolarGX

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    // Your existing code

    // Add: Polar app handles the user activity
    if let userActivity = connectionOptions.userActivities.first {
        _ = PolarApp.shared.continueUserActivity(userActivity)
    }

    // Add: Polar app handles the opening url
    if let url = connectionOptions.urlContexts.first?.url {
        _ = PolarApp.shared.openUrl(url)
    }
}

func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
    // Add: Polar app handles the user activity
    _ = PolarApp.shared.continueUserActivity(userActivity)
}

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    // Add: Polar app handles the opening url
    if let url = URLContexts.first?.url {
        _ = PolarApp.shared.openUrl(url)
    }
}

5. Push Notifications

PolarGX SDK supports push notifications via APNS (Apple Push Notification Service) and GCM/FCM (Google Cloud Messaging / Firebase Cloud Messaging). The SDK automatically registers and manages push tokens for your users.

5.1. Configure Push Service

For APNS (Apple Push Notification Service)

Follow these detailed steps to obtain the required information from Apple Developer Portal. You'll need an active Apple Developer Program membership.

Step 1: Access Apple Developer Portal

  1. Visit https://developer.apple.com/account and sign in with your Apple Developer credentials
  2. Make sure you have admin or account holder access to create authentication keys

Step 2: Navigate to Keys Section

  1. From the left sidebar, select Certificates, Identifiers & Profiles
  2. Click on Keys - this is where you'll manage your APNs authentication keys

Step 3: Create New APNs Key

  1. Click the + button to create a new key
  2. Enter a descriptive name (e.g., "Production Push Notifications")
  3. Check the Apple Push Notifications service (APNs) checkbox
  4. Click Continue and then Register to complete the creation

Step 4: Download Authentication Key

  1. Click Download to save the .p8 file to your computer
  2. Keep this file secure as it provides access to your APNs service

⚠️ Important: This file can only be downloaded once. If you lose it, you'll need to create a new key

Step 5: Record Key ID and Team ID

  1. After creating the key, you'll see a Key ID (a 10-character string like ABC123DEFG) - copy this value
  2. For your Team ID, go to the Membership section in your account settings - it's displayed at the top right (also a 10-character string)

Step 6: Get Your App Bundle ID

  1. Navigate to Identifiers and select your app
  2. The Bundle ID is shown in the format com.yourcompany.yourapp
  3. This identifier must match exactly what's configured in your iOS app's Xcode project

💡 Pro Tip: You can use the same .p8 authentication key for multiple apps within your team. However, each app must have its own unique Bundle ID.

Step 7: Upload APNS Credentials to PolarGX

  1. Go to https://app.polargx.com
  2. Navigate to CONFIGURATIONS > Push Services
  3. Click + New Push Service and select Apple Push Notification Service (APNS)
  4. Fill in the required information:
    • Service Name: Enter a descriptive name
    • Bundle ID: Enter your iOS app's Bundle ID (from Step 6)
    • Team ID: Enter your Team ID (from Step 5)
    • Key ID: Enter the Key ID of your APNS authentication key (from Step 5)
    • Upload your APNS authentication key file: Upload the .p8 file you downloaded (from Step 4)
  5. Click Create or Save to complete the setup

Note: You can create multiple push services for different environments (e.g., one for Production and one for Development). Each service should have a unique Service Name and appropriate configuration.

5.2. Configure PolarGX SDK for Push Notifications

Add Push Notifications Capability

  1. In Xcode, open target settings. In Signing & Capabilities tab, click + Capability.
  2. Add Push Notifications capability.

In AppDelegate.swift:

import PolarGX

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // ... your existing code ...
    
    // Enable notification for your app, then register for remote notifications
    UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { _, _ in
        DispatchQueue.main.async{
            UIApplication.shared.registerForRemoteNotifications()
        }
    }
    
    // For quick integration, you can use our default implementation for Push Notification
    // If you want to use your own UNUserNotificationCenterDelegate implementation, please follow implementation in PolarQuickItegration.swift
    UNUserNotificationCenter.current().delegate = PolarQuickIntegration.userNotificationCenterDelegateImpl;
    
    return true
}

// Handle device token registration
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    // Register APNS token with PolarGX SDK
    PolarApp.shared.setAPNS(deviceToken: deviceToken)
}

// Handle registration failure (optional)
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    print("Failed to register for remote notifications: \(error)")
}