Skip to main content

Installation

Requirements
  • iOS 13.0 or later
  • Swift 5.5 or later
  • Xcode 13 or later
  • A Firebase project for your app

Step 1 - Add the SDK to your project​

Swift Package Manager​

SDK has no bundled dependencies - you need to add three packages manually. In Xcode, go to File → Add Package Dependencies and add each of the following:

PackageURLVersion
UserComSDKhttps://github.com/UserEngage/iOS-SDK0.7.12
Firebase iOS SDKhttps://github.com/firebase/firebase-ios-sdk11.0.0
Gifuhttps://github.com/kaishin/Gifu3.3.1

When adding Firebase, select only the FirebaseMessaging product - you don't need the full Firebase suite.

Add all three packages to your app target. Gifu is required for GIF support in in-app messages.

CocoaPods (legacy)​

CocoaPods support is being phased out. For new projects, use Swift Package Manager above.

If you're maintaining an existing CocoaPods integration, add UserSDK to your Podfile:

platform :ios, '13.0'
use_frameworks!

target 'YourApp' do
pod 'UserSDK', :git => 'https://github.com/UserEngage/iOS-SDK'
end

# Required only if you want push notifications with images
target 'YourApp-NotificationService' do
pod 'UserSDK', :git => 'https://github.com/UserEngage/iOS-SDK'
end

Then run pod install and open the generated .xcworkspace file.


Step 2 - Add your Firebase configuration​

SDK uses Firebase Cloud Messaging internally to deliver push notifications. You don't need to add Firebase as a separate dependency - the SDK bundles it. But you do need to provide your app's GoogleService-Info.plist.

  1. Open Firebase Console and select your project
  2. Go to Project settings → Your apps
  3. Download GoogleService-Info.plist for your iOS app
  4. Drag it into the root of your Xcode project, making sure it's added to your app target
If GoogleService-Info.plist is missing or added to the wrong target, push notifications will not work.

Step 3 - Initialize the SDK​

In your AppDelegate, import the SDK and create the instance inside application(_:didFinishLaunchingWithOptions:).

Your API key and workspace domain are available in the Positive User dashboard under Settings → Workspace Settings → Advanced → Mobile keys. See Setup & Configuration for details.

import UserSDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

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

UserSDK.default = UserSDK(
application: application,
apiKey: "YOUR_API_KEY",
baseURL: "your-domain.user.com",
shouldTrackActivities: false
)

return true
}
}

Replace YOUR_API_KEY with your 64-character Mobile SDK key and your-domain with your Positive User subdomain.


Step 4 - Handle background notifications​

Add the following to your AppDelegate to track notification taps when the app launches from a killed or backgrounded state:

func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) {
UserSDK.default?.handleNotification(userInfo: userInfo)
completionHandler(.newData)
}

SDK only processes notifications tagged by Positive User and ignores everything else, so this won't interfere with your existing notification handling.


What's next​