Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift LSApplicationQueriesSchemes和派生数据_Swift - Fatal编程技术网

Swift LSApplicationQueriesSchemes和派生数据

Swift LSApplicationQueriesSchemes和派生数据,swift,Swift,我想在我的应用程序中打开whatsapp url let whatsAppUrl = NSURL(string: "whatsapp://send?text=Hello%2C%20World!") if UIApplication.sharedApplication().canOpenURL(whatsAppUrl!) { UIApplication.sharedApplication().openURL(whatsAppUrl!) } 我用字典“LSApplicationQuerie

我想在我的应用程序中打开whatsapp url

let whatsAppUrl = NSURL(string: "whatsapp://send?text=Hello%2C%20World!")
if UIApplication.sharedApplication().canOpenURL(whatsAppUrl!) {
    UIApplication.sharedApplication().openURL(whatsAppUrl!)
}
我用字典“LSApplicationQueriesSchemes”扩展了我的info.plist,并为whatsapp添加了我的url方案

<key>LSApplicationQueriesSchemes</key>
<dict>
    <key>Item 0</key>
    <string>whatsapp</string>
</dict>

我阅读了一些清理派生数据的解决方案,并再次运行应用程序来解决此问题。但这对我没有帮助,我的问题还有其他解决方案吗?

您已将LSApplicationQueriesSchemes设置为一个
dict
,它必须是一个数组,如,那么它将工作:)

然后像这样定义查询方案

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>whatsapp</string>
</array>
LSApplicationQueriesSchemes
WhatsApp

非常感谢。现在,我收到一条新的错误消息“-canOpenURL:URL失败:”whatsapp://send?text=Hello%2C%20World!“-错误:”(null)“嗯,奇怪,你确定你现在使用的是数组而不是字典吗?也许试试这个答案,可能是问号有问题吗?错误只出现在xcode中,在我的iphone上一切正常:)谢谢一个lotcan one info.plist有两个LSApplicationQueriesSchemes吗?我也有fb登录。
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>whatsapp</string>
</array>
guard 
   let whatsAppUrl = URL(string: "whatsapp://send?text=Hello%2C%20World!"),
   case let application = UIApplication.shared,
    application.canOpenURL(whatsAppUrl) 
else { return }
application.openURL(whatsAppUrl)
let url = "whatsapp://send?text=Hello World!"
 if let urlString = url.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()) {
  if let whatsappURL = NSURL(string: urlString) {
   if UIApplication.sharedApplication().canOpenURL(whatsappURL) {
       UIApplication.sharedApplication().openURL(whatsappURL)
        } 
       }}
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>whatsapp</string>
</array>