ios - 在我的 iPad 上打开下载的应用程序的 Swift 程序

标签 ios swift ipad button

<分区>

我现在正在开发一个应用程序,我正在尝试创建一个按钮来打开用户已下载的应用程序。感谢之前的问题,我得到了一些工作代码(Swift)。我有以下内容。

@IBAction func Website(_ sender: Any) {

    let powerHooks = "mspbi://app/"

    let powerUrl = NSURL(string: powerHooks)
    if UIApplication.shared.canOpenURL(powerUrl! as URL)
    {
        UIApplication.shared.openURL(powerUrl! as URL)

    } else {
        //redirect to safari because the user doesn't have Power BI
        UIApplication.shared.openURL(NSURL(string: "http://powerbi.microsoft.com")! as URL)
    }
}

基本上,我有一个按钮,单击该按钮应该会打开我 iPad 上的 Microsoft Power BI 应用程序。不幸的是,我不断收到错误消息“此应用程序不允许查询方案 mspbi?我拥有的 URI 直接来自 Microsoft 的网站。关于如何打开该应用程序的想法?它总是跳过“if”并直接转到“else” "

最佳答案

您必须将以下行添加到应用程序的 Info.plist 文件中才能处理应用程序 URL:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>mspbi</string> //not sure if this is the correct entry, you will have to check for the specific app
    <string>uber</string>  //as an example, this is the working entry for opening the Uber app from your app
</array>

关于ios - 在我的 iPad 上打开下载的应用程序的 Swift 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45240926/

相关文章:

ios - 如何在 NavigatorIOS 的选项卡中为 React Native 添加右键

ios - 在 Swift 中使用 "Map"创建两个数组的超集

swift - 是否可以拥有两个不同的位置管理员授权?

ios - 将非更新的已创建交易与已完成交易相关联

ios - 企业无线分发不工作 iOS 5.1.1

iphone - 应用程序的临时分发和撤销访问

objective-c - 尝试创建 UIColor 时发送到类的无法识别的选择器

ios - 隐藏顶部导航栏和底部栏

ios - SpriteKit 是否支持 sprite/texture/shape 的密集镶嵌,以便可以自由变形?

ios - 如果标签重叠,应如何设置应截断哪个标签?