从 Xcode 启动 App Clip 时未调用 SceneDelegate 的 "continue"
SceneDelegate's "continue" not called when launching App Clip from Xcode
我正在尝试通过 运行 连接来自 Xcode 的应用剪辑来测试我的应用剪辑的 url 处理程序。然而,URL 方法处理程序(SceneDelegate
的 continue
方法)永远不会被调用,这与 Apple 的文档 documentation 相反,其中指出:
For a UIKit-based app clip and full app that support scene-based app
life-cycle events, implement the callbacks defined in UISceneDelegate.
For example, implement scene(_:continue:) callback to access the user
activity object.
For a UIKit-based app clip and full app that respond
to app-based life-cycle events, implement the callbacks defined in
UIApplicationDelegate. Be sure to implement the
application(:continue:restorationHandler:) callback, because you
don’t have access to the NSUserActivity object in
application(:didFinishLaunchingWithOptions:).
- app delegate 没有实现
application(_:continue:restorationHandler:)
方法
- 应用剪辑的方案启用了 _XCApplClipURL 参数并设置为
https://fruits.com/check?fruit_name=bananas
- App Clip 的
Associated Domain
列表 appclips:fruits.com
- app clip的
SceneDelegate
如下
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
// UGHH!!! Never gets called
print("AppClip invocation url is : \(incomingURL)")
}
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// OK!! This gets called
guard let _ = (scene as? UIWindowScene) else { return }
}
}
过去两天我一直在用头撞墙。我错过了什么?
注意:我正在使用这个 sample app available in github,只是修改了签名配置以获取要编译的 App Clip & 运行。
感谢您使用 AppsFlyer 的 public App Clip 演示并强调此问题。非常感谢。
我可以确认你做得很好,这个功能在 Beta 5 之后的某个时候被破坏了。
请关注并评论此问题here
提到的 continue
方法仅在您的应用程序先前打开后调用时调用。为了在您的应用程序首次启动时获得 _XCApplClipURL
中设置的值,您需要使用您提到的第二种方法 (scene willConnectTo session
)。
您可以尝试这样的操作:
if let activity = connectionOptions.userActivities.filter({ [=10=].activityType == NSUserActivityTypeBrowsingWeb }).first {
if let url = activity.webpageURL {
print("incoming URL: \(url)")
}
}
我正在尝试通过 运行 连接来自 Xcode 的应用剪辑来测试我的应用剪辑的 url 处理程序。然而,URL 方法处理程序(SceneDelegate
的 continue
方法)永远不会被调用,这与 Apple 的文档 documentation 相反,其中指出:
For a UIKit-based app clip and full app that support scene-based app life-cycle events, implement the callbacks defined in UISceneDelegate. For example, implement scene(_:continue:) callback to access the user activity object.
For a UIKit-based app clip and full app that respond to app-based life-cycle events, implement the callbacks defined in UIApplicationDelegate. Be sure to implement the application(:continue:restorationHandler:) callback, because you don’t have access to the NSUserActivity object in application(:didFinishLaunchingWithOptions:).
- app delegate 没有实现
application(_:continue:restorationHandler:)
方法 - 应用剪辑的方案启用了 _XCApplClipURL 参数并设置为
https://fruits.com/check?fruit_name=bananas
- App Clip 的
Associated Domain
列表appclips:fruits.com
- app clip的
SceneDelegate
如下
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
// UGHH!!! Never gets called
print("AppClip invocation url is : \(incomingURL)")
}
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// OK!! This gets called
guard let _ = (scene as? UIWindowScene) else { return }
}
}
过去两天我一直在用头撞墙。我错过了什么?
注意:我正在使用这个 sample app available in github,只是修改了签名配置以获取要编译的 App Clip & 运行。
感谢您使用 AppsFlyer 的 public App Clip 演示并强调此问题。非常感谢。
我可以确认你做得很好,这个功能在 Beta 5 之后的某个时候被破坏了。
请关注并评论此问题here
提到的 continue
方法仅在您的应用程序先前打开后调用时调用。为了在您的应用程序首次启动时获得 _XCApplClipURL
中设置的值,您需要使用您提到的第二种方法 (scene willConnectTo session
)。
您可以尝试这样的操作:
if let activity = connectionOptions.userActivities.filter({ [=10=].activityType == NSUserActivityTypeBrowsingWeb }).first {
if let url = activity.webpageURL {
print("incoming URL: \(url)")
}
}