我有一个带有 href="whatsapp:+(xxxxxxxxx)" anchor 的网页,如果我在我的 iPhone (iOS 9) 上点击它,它会在该联系人的聊天 View 中打开 WhatsApp(我可以查看我与联系人进行的所有聊天)。 但是,如果我以编程方式执行此操作(相同的 url),它只会在聊天选项卡上打开 WhatsApp。
我尝试过其他方法(使用地址簿 API,并使用“whatsapp://send?abid=RECORDID”),但都失败了。
任何帮助将不胜感激。
最佳答案
您应该将 WhatsApp URL 方案添加到您的应用程序 Info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>whatsapp</string>
</array>
根据 Apple Developer documentation
IMPORTANT If your app is linked on or after iOS 9.0, you must declare the URL schemes you want to pass to this method. Do this by using the LSApplicationQueriesSchemes array in your Xcode project’s Info.plist file. For each URL scheme you want your app to use with this method, add it as a string in this array.
If your (iOS 9.0 or later) app calls this method using a scheme you have not declared, the method returns NO, whether or not an appropriate app for the scheme is installed on the device.
关于IOS - 无法以编程方式打开 Whatsapp 聊天,但可以通过 HTML 进行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36066770/