Skip to content

iOS Mobile SDK Upgrade Guide

Version 2.44.16 and Later

Dropped Support for iOS 12

As outlined in the Getting Started section, Tapkey officially supports the latest three major iOS versions. Older versions are supported on a best-effort basis. To leverage new iOS features, support for iOS 12 has been dropped starting with this Mobile SDK version.

If your target application currently supports iOS 12 as the deployment target, you must reconfigure it to support at least iOS 13 or later.

Updating the Target iOS Version

Update the target iOS version in your Podfile:

target 'App' do
  platform :ios, '13.0'
  ...
end

Additionally, update the deployment target in Xcode:

  1. Open your project in Xcode.
  2. Navigate to the General section.
  3. Select 13.0 or a later version in the Minimum Deployment section.

Added Singleton

To simplify initialization and make the Mobile SDK access more idiomatic for iOS, a new singleton class has been introduced. Instead of manually managing an instance of TapkeyServiceFactory in the target's AppDelegate or elsewhere, the SDK now provides a global singleton instance: TapkeyMobileSdk.serviceFactory.

Use the static method TapkeyMobileSdk.initialize() to initialize the SDK, passing a closure to configure the serviceFactoryBuilder.

Updating Initialization

Before:

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    private var _serviceFactory: TKMServiceFactory!

    public var serviceFactory: TKMServiceFactory {
        return self._serviceFactory
    }

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

        self._serviceFactory = TKMServiceFactoryBuilder()
            // Perform your configuration
            ...
            .build()
    }
}

After:

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

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

        TapkeyMobileSdk.initialize { builder in
            builder
              // Perform your configuration
        }
    }
}

Updating References

Before:

func doSomething() {
    let appDelegate = UIApplication.shared.delegate as! AppDelegate
    let serviceFactory = appDelegate.serviceFactory
    // Perform actions with Tapkey services
}

After:

func doSomething() {
    let serviceFactory = TapkeyMobileSdk.serviceFactory
    // Perform actions with Tapkey services
}

Replaced Background Fetch

Starting with iOS 13, Background Fetch has been replaced with Background Processing. If your app targets iOS 13 or later, Background Fetch is no longer available.

Enabling Background Processing

  1. Open your project in Xcode.
  2. Navigate to the Signing & Capabilities section.
  3. In the Background Modes section:
    • Disable the Background Fetch option.
    • Enable the Background Processing option.

Updating Code

  1. Remove configuration of background fetch in didFinishLaunching function from the AppDelegate:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
        // remove
        UIApplication.shared.setMinimumBackgroundFetchInterval(TKMDefaultMinimumBackgroundFetchIntervalSec)
    }
    
  2. Remove the performFetchWithCompletionHandler function from the AppDelegate:

    func application(
        _ application: UIApplication,
        performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
    ) {
        runAsyncInBackground(application) { _ in
            TKMServiceFactory.notificationManager
                .pollForNotificationsAsync(cancellationToken: TKMCancellationTokens.None)
                .finallyOnUi {
                    completionHandler(UIBackgroundFetchResult.newData)
                }
        }
    }
    
  3. Use the updated initialization process to enable background polling:

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
    
        TapkeyMobileSdk.initialize { builder in
            // Enables background polling with the default interval of 8 hours
            builder
                .withBackgroundPolling()
    
            // Or configure a polling interval that fits your requirements
            // builder
            //   .withBackgroundPolling(interval: 12 * 60 * 60)
        }
    }