在外部唤醒iOSApp
URL Scheme、Universal Links两种方式都可以,但是Universal Links方式更稳定。iOS13+以上环境URL Scheme方式可能被系统拦截。 URL Scheme方式 配置Info.plist 打开App工程的Info.plist ,添加URL types CFBundleURLTypes CFBundleURLName 一个名字,例如myapp CFBundleURLSchemes 自定义scheme,例如myapptest AppDelegate回调 func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { //解析url,路由到App内对应页面 myapptest://xxx/yyy?zzz=123 print(url) return true } SceneDelegate回调(iOS13+) func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { guard let context = URLContexts.first else { return } let url = context.url //解析url,路由到App内对应页面 myapptest://xxx/yyy?zzz=123 print("SceneDelegate 收到scheme url:\(url)") } 外部唤醒 以 Safari 为例 <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>唤醒测试</title> </head> <body> <a href="myapptest://xxx/yyy?zzz=123">通过URL Scheme唤醒</a> </body> </html> Universal Links方式 请先阅读配置Apple-Universal-Links ...