简体   繁体   English

使用android / ios应用程序发送whatsapp消息

[英]Send whatsapp message using android/IOS aplication

What is the best way to open the WhatsApp application to send a message? 打开WhatsApp应用程序发送消息的最佳方法是什么?

I wrote this code because I want it to open in one way through the computer browser, and otherwise by the mobile application. 我写这段代码是因为我希望它可以通过计算机浏览器以一种方式打开,否则希望通过移动应用程序来打开。

First I made a condition to check where the user is accessing. 首先,我创建了一个条件来检查用户正在访问的位置。 If it is by some mobile device, it falls in the first condition, otherwise, it falls on the second link. 如果是通过某个移动设备,则它处于第一种状态,否则,它处于第二条链路上。

The condition of opening the application is not working, I think it may be the 'whatsapp: // ...' link can anyone help me? 打开应用程序的条件不起作用,我认为可能是“ whatsapp:// ...”链接有人可以帮助我吗?

        function MakeLink() {
            if ( isMobile.any ) {
                let target = 'whatsapp://send?'
                    target += 'phone='+ encodeURIComponent(phone);
                return target
            } else {
                let target = 'https://web.whatsapp.com/send?'
                    target += 'phone='+ phone;
                return target
            }

        }

    window.location.href = MakeLink();

Ps: I do not want to use the 'api.whatsapp' address because it drops to an intermediate page, increasing the client path. 附:我不想使用“ api.whatsapp”地址,因为它放到中间页面,增加了客户端路径。

I dont know if there is another way without api 我不知道没有api是否还有另一种方法

let target = 'https://api.whatsapp.com/send?'
  target += 'phone='+ phone;

EDIT: it suddenly stopped working since yesterday. 编辑:从昨天开始它突然停止工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM