【问题标题】:Can iOS Today Extension read URL Schemes from app's Info.plistiOS Today Extension 能否从应用的 Info.plist 中读取 URL 方案
【发布时间】:2015-01-30 23:30:48
【问题描述】:

我们有我们的应用程序目标,在 Info.plist 中,我们定义了 URL 方案,可用于通过 URL 打开应用程序。

现在我们正在添加今天的扩展。我们将希望有一个表格视图,它将从扩展中打开该 URL。我们看到了 API 是如何支持它的。

我们能否从应用的 Info.plist 中获取 URL 方案,或者我们基本上是“硬编码”扩展中的值以使其调用打开?

【问题讨论】:

    标签: swift ios8 ios8-extension ios8-today-widget today-extension


    【解决方案1】:

    要获取 infos.plist 值,您可以使用:

    let urlTypesArray = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleURLTypes")
    

    你可以找到正确的键(CFBundleURLTypes)打开info.plist作为源代码(右键单击)

    然后,找到值:

    let urlSchemesValue = urlTypesArray![0]["CFBundleURLSchemes"]
    print("urlSchemesValue => \(urlSchemesValue)") 
    

    【讨论】:

      【解决方案2】:

      @damien 的回答不正确。这只会返回 Extension Info.plist 文件。

      正确答案可以在另一个 SO 帖子中找到here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-09
        相关资源
        最近更新 更多