Send a message via Whatsapp to a specific contact

Asked

Viewed 2,782 times

-1

I’m trying to send a text message via Whatsapp to a previously selected number. The contact chat opens, but the message contained in Extras does not appear in the text box. See:

var uri = Android.Net.Uri.Parse("smsto:" + "55" + (number));
Intent i = new Intent(Intent.ActionSendto, uri);
i.PutExtra("sms_body", "Instale meu novo aplicativo!");
i.SetPackage("com.whatsapp");
StartActivity(i);

PS.: no exception is thrown.

2 answers

1


I managed to find a way that works:

Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.PutExtra("jid", "55" + (number) + "@s.whatsapp.net");
sendIntent.PutExtra(Intent.ExtraText, "Instale meu novo aplicativo!");
sendIntent.SetAction(Intent.ActionSend);
sendIntent.SetPackage("com.whatsapp");
sendIntent.SetType("text/plain");
StartActivity(sendIntent);

0

Try this:

String url = "https://api.whatsapp.com/send?phone=559599111111";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.