whatsapp(如何分享whatsapp账号)

未标题-1-4 (1).png

大家好,在这个博客中,我们将学习如何从我们的 .net Maui 应用程序发送 WhatsApp 消息。

MainPage.xaml

这是我们应用程序的 UI 代码,有 2 个条目,一个用于手机号码,一个用于消息,以及一个用于发送消息的按钮。

<?xml version="1.0" encoding="utf-8" ?><ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyApp.MainPage"> <VerticalStackLayout HorizontalOptions="CenterAndExpand" Spacing="20" VerticalOptions="CenterAndExpand"> <Frame BorderColor="Black" Padding="15,5,15,5"> <Entry x:Name="numberEntry" ReturnType="Next" MaxLength="10" PlaceholderColor="Gray" Keyboard="Numeric" Placeholder="Enter Mobile Number"/> </Frame> <Frame BorderColor="Black" Padding="15,5,15,5"> <Entry x:Name="messageEntry" ReturnType="Done" PlaceholderColor="Gray" Placeholder="Enter Your Message"/> </Frame> <Button Text="Send Whatsapp Message" BorderColor="Black" BorderWidth="1" FontAttributes="Bold" Padding="25,15,25,15" BackgroundColor="#25D366" Clicked="SendMessage"/> </VerticalStackLayout></ContentPage>

MainPage.xaml.cs

namespace MyApp;public partial class MainPage : ContentPage{public MainPage{InitializeComponent;}/// <summary>/// Sends provided message on whatsapp number/// </summary>/// <param name="phoneNumber">Number on which message will be sent</param>/// <param name="message">Message to send</param>private async void SendWhatsapp{ bool supportsUri=await Launcher.Default.CanOpenAsync; if await Launcher.Default.OpenAsync; else await App.Current.MainPage.DisplayAlert; } /// <summary> /// Send message button clicked /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void SendMessage{ string number="+91 "+numberEntry.Text;SendWhatsapp; }}

注意:我在发送 WhatsApp 消息之前添加了国家代码。 您可以根据需要提供国家/地区代码的下拉列表。

使用 Maui 的 Launcher 启动 WhatsApp 以向特定的手机号码发送消息。

感谢您阅读我的博客直到这里。 快乐编码。

关注七爪网,获取更多APP/小程序/网站源码资源!

海外精品引流脚本–最强海外引流  

官网:www.facebook18.com

唯一TG:https://t.me/Facebook181818

Facebook.png

更多海外引流脚本方案

如果你需要脚本演示、部署咨询或海外获客方案,可以通过下面入口继续查看。

官网首页 | 演示视频 | TG 在线客服 | TG 频道

相关阅读

© 版权声明
广告也精彩

相关文章