Open Whatsapp intent (with msg & specific contact)

#1

Not sure if its a ngCordova of Ionic 2 question, so if an admin/moderator wants to move it around, please go ahead.

Anyway, i am using the Ionic2-framework for a mobile website, but now i want to make it een APK, and running into a problem. The whatsapp href i use doesn’t work anymore. Chrome on mobile accepts:

intent://send/0123456789#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end

This will start a conversation with a user with phone number 0123456789, or ask if you want to add it to my contacts so i can whatsapp with that person.

But in the APK i don’t get it to work, errorlog:

Error loading url intent://send/0123456789#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=intent://send/0123456789}
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1809)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
at android.app.Activity.startActivityForResult(Activity.java:4224)
at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:342)
at android.app.Activity.startActivityForResult(Activity.java:4183)
at android.app.Activity.startActivity(Activity.java:4507)
at android.app.Activity.startActivity(Activity.java:4475)
at org.apache.cordova.CordovaWebViewImpl.showWebPage(CordovaWebViewImpl.java:237)
at org.apache.cordova.CordovaWebViewImpl$EngineClient.onNavigationAttempt(CordovaWebViewImpl.java:606)
at org.apache.cordova.engine.SystemWebViewClient.shouldOverrideUrlLoading(SystemWebViewClient.java:79)
at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:73)
at com.android.webview.chromium.WebViewContentsClientAdapter.shouldOverrideUrlLoading(WebViewContentsClientAdapter.java:339)
at org.chromium.android_webview.AwContentsClient.shouldIgnoreNavigation(AwContentsClient.java:168)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(AwContentsClientBridge.java:256)
at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:39)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Now that suggests that whatsapp or intent is not present in the app or on my phone.

Anyone who knows where it goes wrong? I did add this to the config.xml:

<allow-intent href=“intent:*” />

#2

Hello @schaap

I need to do the same, could you achieve this?

#3

For now we just don’t use the web app in an APK, but just through a browser, then the intent: url-scheme works fine.

Didn’t find a solution to get it working in an app…

#4

My colleague and i found a solution:

Phone works for Android and abid works for iOS…

You need this in config.xml as well:

#5

i can’t properly understand what u looking for but if u want to chat with specific person in whatsapp then here is the solution.

//in my html or template
openURL(‘whatsapp://send?text=Hello&phone=+919904880561’)

//in my controller
$scope.openURL = function(num){
window.open(url,"_system",“location=yes”);
};

1 Like
#6

You are my hero. On Android all of the solutions I tried work, but on iOS only worked window.open. THANK YOU!

1 Like