【问题标题】:openUrl not being called when I launch the app from Scheme Url当我从 Scheme Url 启动应用程序时未调用 openUrl
【发布时间】:2018-12-26 01:16:42
【问题描述】:

这可能是一个新手问题。

当应用程序在后台并单击方案 URL(类似于“myApp://blabla”)以启动应用程序时,打开 url 方法工作正常。没问题。

但是当应用程序不在后台或通过向上滑动而终止时,然后我单击 url(myApp://blabla) 应用程序启动但不调用 AppDelegate 中的 openUrl 方法。

所以,我无法正确导航应用程序。

已解决:正如@ctietze 所说,didFinishLaunchingWithOptions 不是 return true,这就是问题所在。

【问题讨论】:

标签: ios callback appdelegate openurl


【解决方案1】:

在这种情况下你必须检查didFinishLaunchingWithOptions委托方法

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
   if let url = launchOptions?[UIApplication.LaunchOptionsKey.url] as? URL {
      /// some
   }
 return true
}

【讨论】:

    【解决方案2】:

    确保您已在 info.plist 文件的 URL 类型下添加“myApp”所有详细信息。 您需要在其中添加两个键。查看下图:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-07
      • 2010-11-23
      • 1970-01-01
      • 1970-01-01
      • 2015-01-20
      • 1970-01-01
      • 1970-01-01
      • 2013-03-21
      相关资源
      最近更新 更多