[Xcode 27] SceneDelegate Migration Required — Additional Setup Needed for Airbridge Deep Links
[Xcode 27] SceneDelegate Migration Required — Additional Setup Needed for Airbridge Deep Links
AttentionThis troubleshooting guide is for customers who need to migrate an existing AppDelegate-based app to the UIScene(SceneDelegate) lifecycle.
Problem
- When you run an app built with Xcode 27, the screen appears blank (white) or the app does not render properly.
- Airbridge deep link events are not collected even when the app is opened through a scheme deep link or Universal Link.
- The
setDeeplinkListenercallback is not called. - The app does not work even though the code was added to
AppDelegateas shown in the SDK Installation and Deep Link Setup developer guide examples.
Cause
Apple is moving the app lifecycle from theUIApplicationDelegate-only AppDelegate model to the UIScene-based SceneDelegate model, and adopting the Scene lifecycle has effectively become required in the latest Xcode and iOS environments.When an app adopts the Scene lifecycle through UIApplicationSceneManifest, the following AppDelegate callbacks are no longer called.In cordova-ios 7.x and earlier,
CDVAppDelegate creates the window and MainViewController in application:didFinishLaunchingWithOptions:.In the Scene lifecycle, SceneDelegate owns the window, so this window is not displayed and the screen appears blank.Solution
The required work depends on your cordova-ios platform version.Check the version withcordova platform ls, then select the matching tab in each step below.Attention
CDVSceneDelegate in cordova-ios 8.0.0 / 8.0.1 does not implement scene:continueUserActivity:.Applying the code below causes the app to terminate when it is opened through a Universal Link.Update to cordova-ios 8.1.0 or later before applying this guide.AttentionFiles under
platforms/ios are reset when you run cordova platform rm/add.Manage the files using <config-file> and <source-file> in config.xml or a hook, or include the platforms directory in version control.1. Add Scene Manifest to Info.plist
AttentionThe
UISceneDelegateClassName value must match the language used to implement SceneDelegate: $(PRODUCT_MODULE_NAME).SceneDelegate for Swift and SceneDelegate for Objective-C.A Swift class is registered with the Objective-C runtime as <module>.SceneDelegate.If the value does not match, the scene connection fails and the screen appears blank.- cordova-ios 8.1.0 or later
- cordova-ios 7.x or earlier
This is included by default in
platforms/ios/App/App-Info.plist.Confirm that no values are missing.UISceneStoryboardFile must be set to Main.Without this value, the screen appears blank.2. Create SceneDelegate and move the deep link collection code to SceneDelegate
The code below uses the default template language for each cordova-ios version: Swift for 8.1.0 or later and Objective-C for 7.x or earlier.If you implement it in the other language, also apply the following.- When implementing cordova-ios 8.1.0 or later in Objective-C: Delete the default
App/SceneDelegate.swiftfile and changeUISceneDelegateClassNameinApp-Info.plisttoSceneDelegate. Add#import "AirbridgeCO.h"to callAirbridgeCO. - When implementing cordova-ios 7.x or earlier in Swift: Change
UISceneDelegateClassNameto$(PRODUCT_MODULE_NAME).SceneDelegate. In the defaultplatforms/ios/YOUR_PROJECT_NAME/Bridging-Header.hfile, add#import "AppDelegate.h",#import "MainViewController.h",#import <Cordova/CDVPlugin.h>, and#import "AirbridgeCO.h".
- cordova-ios 8.1.0 or later
- cordova-ios 7.x or earlier
Update
platforms/ios/App/SceneDelegate.swift as follows.AttentionIn cordova-ios 8.1.0 or later, do not additionally call
handleURLSchemeDeeplink(_:) with connectionOptions.urlContexts in scene(_:willConnectTo:options:).CDVSceneDelegate forwards it to scene(_:openURLContexts:), so the deep link is collected twice at cold start.3. Clean up AppDelegate
- Keep the SDK initialization code (
getInstance:appName:withLaunchOptions:) inapplication:didFinishLaunchingWithOptions:as is. application:openURL:options:andapplication:continueUserActivity:restorationHandler:, which were added for deep link collection, are not called in the Scene lifecycle. After moving them toSceneDelegate, remove them fromAppDelegate.- For cordova-ios 7.x and earlier, delete
self.viewController = [[MainViewController alloc] init];andreturn [super application:application didFinishLaunchingWithOptions:launchOptions];, and replace them withreturn YES;. The defaultCDVAppDelegateimplementation creates a newwindowandCDVViewController. If left unchanged, it creates a second Cordova web view that is not displayed.
Update 1.X.X → 2.X.X
Update 1.X.X → 2.X.X
The event API has been replaced to the below.Refer to the Cordova 2.X.X migration guide for details.
Bitcode Compile Error
Bitcode Compile Error
An error like below may occur when creating iOS builds with Cordova Ionic PhoneGap SDK v2.0.1+.Since Cordova Ionic PhoneGap SDK v2.0.1+ uses Airbridge iOS SDK v1.28.0+, Bitcode is no longer supported. Please refer to the Bitcode compile error guide for more details.
Update 1.1.X → 1.2.X
Update 1.1.X → 1.2.X
Uninstall the old version of the Airbridge SDK.Cordova:
cordova plugin remove airbridge-cordova-sdkIonic: ionic cordova plugin remove airbridge-cordova-sdkPhoneGap: phonegap plugin remove airbridge-cordova-sdkInstall the new version of the Airbridge SDK.Cordova: cordova plugin add airbridge-cordova-sdkIonic: ionic cordova plugin add airbridge-cordova-sdkPhoneGap: phonegap plugin add airbridge-cordova-sdkAndroid
Modifyandroid/app/src/main/java/.../MainActivity as below.iOS
Modifyios/[Project Name]/AppDelegate as below.Settings
- Add an
airbridge.jsonfile to the project folder. - Add the parameters shown in the example below in JSON format.
Example
Description
Update 1.0.X → 1.1.X
Update 1.0.X → 1.1.X
Install
Uninstall the old version of the Airbridge SDK.Cordova:cordova plugin remove airbridge-cordova-sdkIonic: ionic cordova plugin remove airbridge-cordova-sdkPhoneGap: phonegap plugin remove airbridge-cordova-sdkInstall the new version of the Airbridge SDK.Cordova: cordova plugin add airbridge-cordova-sdkIonic: ionic cordova plugin add airbridge-cordova-sdkPhoneGap: phonegap plugin add airbridge-cordova-sdksetDeeplinkListenerRemove the getInitialDeeplink function and use the setDeeplinkListener function only.Android
AndroidManifest.xmlIn the MainActivity section of the android/app/src/main/AndroidManifest.xml file, add intent-filter parameters as below.MainActivity.java
Modify android/app/src/main/java/.../MainActivity.java as below.iOS
Universal Link
- Go to “Xcode → Project file → Signing & Capabilities”.
- Click ”+ Capability” and add “Associated Domains”.
- Add
applinks:YOUR_APP_NAME.deeplink.pageto “Associated Domains”.
YOUR_APP_NAME can be found at the “Airbridge dashboard → Settings → Tokens → App Name”. AppDelegate.mModify ios/.../AppDelegate.m as below.