To use .Net Maui to send a message on WhatsApp, you can follow these steps:
Add the Xamarin.Essentials NuGet package to your .Net Maui project.
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.
Ensure that the recipient has WhatsApp installed on their phone and that their phone number is correct.
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.
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
Asked: 2021-06-28 11:00:00 +0000
Seen: 15 times
Last updated: Aug 01 '22
Is it possible to globally install System.Data.OleDb?
What is the method to discover and terminate a process in .net?
Does Asp .Net Core Identity log out automatically after a certain period of time?
Why isn't the user interface updating when adding a custom object with data binding in .NET MAUI?
How can an application communicate with a service in the C# .NET Framework?
How can I send messages to multiple phone numbers using Twilio SMS and .net?
What is the process for working with dynamics 365 using .net 6/7?