Manual Integration in Swift

Prev Next

Goal

Manually integrate the Mapp Engage SDK into your iOS app using Swift.

Note:

  • This guide covers manual integration for advanced users who need greater customization.

  • For basic integration, see the Basic Automated Setup.

Prerequisites

Before beginning, ensure:

  1. Xcode Requirements:

    • Base SDK: iOS 12 or higher.

    • Deployment Target: iOS 12 or higher.

  2. Mapp Engage Account:

    • An account on the Mapp Engage dashboard with a configured application.

Procedure

  1. Download the SDK

  2. Add the SDK to Your Project: Drag AppoxeeSDK.xcframework into your project.

  3. Import the SDK: Add the following to your Objective-C bridging header:

    #import <AppoxeeSDK/AppoxeeSDK.h>
  4. Set Up Delegates: Declare the AppDelegate class with the following:

    class AppDelegate: UIResponder, UIApplicationDelegate, AppoxeeNotificationDelegate {
        // Class implementation
    }
  5. Configure didFinishLaunchingWithOptions: Add the initialization code in the application:didFinishLaunchingWithOptions: method:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        Appoxee.shared()?.engage(withLaunchOptions: launchOptions, andDelegate: nil, andSDKID: "Your_SDK_ID", with: .L3)
        return true
    }

    The with parameter is the SERVER enum. Customer-facing values are L3, EMC, EMC_US, and CROC. Your account manager will tell you which one to use.

    Note:

    The SERVER enum also defines TEST, TEST55, and TEST61 values. These are internal test environments and are not meant for production use.

  6. Handle Notifications: Implement the following methods:

    • Register for Notifications:

      func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
          Appoxee.shared()?.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
      }
    • Receive Remote Notifications:

      func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
          Appoxee.shared()?.receivedRemoteNotification(userInfo)
          completionHandler(.newData)
      }
  7. Optional Push Features

    • Custom Push Notification Categories: Register categories before calling engage(...) and pass them to the SDK using saveUserNotificationCategories(_:):

      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
          UNUserNotificationCenter.current().delegate = self
          UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { _, _ in }
          application.registerForRemoteNotifications()
      
          let viewAction = UNNotificationAction(identifier: "view_now", title: "View", options: .foreground)
          let skipAction = UNNotificationAction(identifier: "skip", title: "Skip", options: .foreground)
          let category = UNNotificationCategory(identifier: "CUSTOM_CATEGORY_NAME",
                                                actions: [viewAction, skipAction],
                                                intentIdentifiers: [],
                                                hiddenPreviewsBodyPlaceholder: "",
                                                options: .customDismissAction)
      
          UNUserNotificationCenter.current().setNotificationCategories([category])
          Appoxee.shared()?.saveUserNotificationCategories([category])
      
          Appoxee.shared()?.engage(withLaunchOptions: launchOptions, andDelegate: nil, andSDKID: "Your_SDK_ID", with: .L3)
          return true
      }
  8. Appoxee Delegate (Optional): Handle custom push actions by implementing:

    func appoxee(_ appoxee: Appoxee, handledRemoteNotification pushNotification: APXPushNotification, andIdentifer actionIdentifier: String) {
        // Handle the custom push action
    }

    Warning:

    The selector appoxee:handledRemoteNotification:andIdentifer: contains a typo (Identifer without the second i) in the public header. Use the selector exactly as shown — it matches the symbol exported by AppoxeeSDK.xcframework.