How to Open Whatsapp app from other app with a specific contact in ionic 3?

3.3k views Asked by At

I've developed an ionic 3 app. I am unable to open whatsapp from my app with a specific contact in ionic 3. i don't want to send or share any thing but only wants to open whatsapp in android & iOS from my app with a specific contact. Is there any way to open whatsapp? Till now i have implemented as below which is not working

window.open(`whatsapp:${+911234567890}`, '_system');

Any help much appreciate.

2

There are 2 answers

0
Lucas Pedroso On BEST ANSWER

See it: http://phonegap-plugins.com/plugins/ranjitpandit/whatsapp-phonegap-plugin

cordova.plugins.Whatsapp.send("yourNumber", sucessoCallback, errorCallback);

0
Hridoy Krisna Das On

I am Using this:

            String phone = "+8801510101010";

            PackageManager packageManager = MainActivity.this.getPackageManager();
            Intent i = new Intent(Intent.ACTION_VIEW);

            try {
                String url = "https://api.whatsapp.com/send?phone="+ phone;
                i.setPackage("com.whatsapp");
                i.setData(Uri.parse(url));
                if (i.resolveActivity(packageManager) != null) {
                    MainActivity.this.startActivity(i);
                }
            } catch (Exception e){
                e.printStackTrace();
            }