Ask Your Question
3

How can I use .Net Maui to send a message on WhatsApp?

asked 2021-06-28 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-08-01 22:00:00 +0000

scrum gravatar image

To use .Net Maui to send a message on WhatsApp, you can follow these steps:

  1. Add the Xamarin.Essentials NuGet package to your .Net Maui project.

  2. Use the following code to open WhatsApp and send the message:

using Xamarin.Essentials;

var message = "Hello, world!";
var recipient = "+123456789"; // the phone number of the recipient in the international format

await Launcher.OpenAsync($"whatsapp://send?phone={recipient}&text={message}");

Replace Hello, world! with the message you want to send and +123456789 with the phone number of the recipient.

  1. Ensure that the recipient has WhatsApp installed on their phone and that their phone number is correct.

  2. Run your .Net Maui app and click the button or perform the action that triggers the code above to send the message on WhatsApp.

Note that sending messages on WhatsApp via code requires the WhatsApp app to be installed on the device. If the app is not install, an exception will be thrown.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-06-28 11:00:00 +0000

Seen: 15 times

Last updated: Aug 01 '22