Send a message via WhatsApp to a specific contact

0

I'm trying to send a text message via WhatsApp to a previously selected number. The contact's chat opens, but the message contained in Extras does not appear in the text field. 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 thrown.

    
asked by anonymous 21.02.2018 / 15:29

1 answer

0

I was able 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);
    
21.02.2018 / 17:55