iOS-无法以编程方式打开Whatsapp聊天,但可以通过HTML进行 [英] IOS - Can't open Whatsapp chat programatically, but can do it through HTML

查看:84
本文介绍了iOS-无法以编程方式打开Whatsapp聊天,但可以通过HTML进行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个锚点为href ="whatsapp:+(xxxxxxxxx)"的网页,如果我在iPhone(iOS 9)上单击该网页,则会在聊天视图中为该联系人打开WhatsApp(我可以查看我与联系人进行的所有聊天).但是,如果我以编程方式(相同的网址)执行此操作,则只会在聊天选项卡上打开WhatsApp.

I have a Web page with an anchor that has href="whatsapp:+(xxxxxxxxx)", if i click on it on my iPhone (iOS 9), it opens WhatsApp in the chat view for that contact (i can see all the chats that i did with the contact). However, if i do it programmatically (same url), it only opens WhatsApp on the chat tab.

我尝试了其他方法(使用通讯簿api,并使用"whatsapp://send?abid = RECORDID"),但都失败了.

I've tried other ways of doing this (using the Address Book api, and using the "whatsapp://send?abid=RECORDID"), but all fail.

任何帮助将不胜感激.

推荐答案

您应将WhatsApp URL方案添加到应用程序Info.plist

You should add the WhatsApp URL scheme to your application Info.plist

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

根据 Apple Developer文档

重要如果您的应用在iOS 9.0或更高版本上链接,则必须声明要传递给此方法的URL方案.为此,请使用Xcode项目的Info.plist文件中的LSApplicationQueriesSchemes数组.对于您希望应用程序使用此方法的每种URL方案,请将其作为字符串添加到此数组中.

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.

如果您(iOS 9.0或更高版本)的应用程序使用尚未声明的方案调用此方法,则无论设备上是否安装了适合该方案的应用程序,该方法都将返回NO.

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进行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆