这是我使用的代码:
let instagramURL = NSURL(string: "instagram://app")
if UIApplication.shared.canOpenURL(instagramURL! as URL) {
//Code
} else {
//Showing message "Please install the Instagram application"
}
Run Code Online (Sandbox Code Playgroud)
我输入if循环失败了.
我收到此错误:
canOpenURL:网址失败:"instagram:// app" - 错误:"此应用不允许查询方案instagram"
我也在我的设备中登录Instagram.
Mad*_*ddy 40
右键单击plist文件并将其作为源代码打开.然后复制并粘贴下面的代码:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
</array>
Run Code Online (Sandbox Code Playgroud)
注意:有一点你必须记住,它不适用于模拟器.你需要一个真正的设备.
打开plist作为源代码并粘贴以下代码:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
</array>
Run Code Online (Sandbox Code Playgroud)
对于那些尝试使用自定义 URL 方案打开应用程序的用户(假设应用程序 FirstApp 打开 SecondApp):
LSApplicationQueriesSchemesURL 方案添加到 Info.plist,如下所示:| 归档时间: |
|
| 查看次数: |
8456 次 |
| 最近记录: |