Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Essentials SMS API Docs #12849

Merged
merged 3 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions src/Essentials/docs/Microsoft.Maui.Essentials/Sms.xml

This file was deleted.

110 changes: 0 additions & 110 deletions src/Essentials/docs/Microsoft.Maui.Essentials/SmsMessage.xml

This file was deleted.

1 change: 0 additions & 1 deletion src/Essentials/src/Sms/Sms.netstandard.tvos.watchos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Microsoft.Maui.ApplicationModel.Communication
{
/// <include file="../../docs/Microsoft.Maui.Essentials/Sms.xml" path="Type[@FullName='Microsoft.Maui.Essentials.Sms']/Docs/*" />
partial class SmsImplementation : ISms
{
public bool IsComposeSupported
Expand Down
59 changes: 50 additions & 9 deletions src/Essentials/src/Sms/Sms.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,52 @@

namespace Microsoft.Maui.ApplicationModel.Communication
{
/// <summary>
/// The SMS API enables an application to open the default SMS application with a specified message to send to a recipient.
/// </summary>
public interface ISms
{
/// <summary>
/// Gets a value indicating whether composing of SMS messages is supported on this device.
/// </summary>
bool IsComposeSupported { get; }

/// <summary>
/// Opens the default SMS client to allow the user to send the message.
/// </summary>
/// <param name="message">A <see cref="SmsMessage"/> instance with information about the message to send.</param>
/// <returns>A <see cref="Task"/> object with the current status of the asynchronous operation.</returns>
Task ComposeAsync(SmsMessage? message);
}

/// <include file="../../docs/Microsoft.Maui.Essentials/Sms.xml" path="Type[@FullName='Microsoft.Maui.Essentials.Sms']/Docs/*" />
/// <summary>
/// The SMS API enables an application to open the default SMS application with a specified message to send to a recipient.
/// </summary>
/// <remarks>When using this on Android targeting Android 11 (R API 30) you must update your Android Manifest with queries that are used with the new package visibility requirements. See the conceptual docs for more information.</remarks>
public static class Sms
{
/// <include file="../../docs/Microsoft.Maui.Essentials/Sms.xml" path="//Member[@MemberName='ComposeAsync'][1]/Docs/*" />
/// <summary>
/// Opens the default SMS client to allow the user to send the message.
/// </summary>
/// <returns>A <see cref="Task"/> object with the current status of the asynchronous operation.</returns>
public static Task ComposeAsync()
=> Current.ComposeAsync(null);

/// <include file="../../docs/Microsoft.Maui.Essentials/Sms.xml" path="//Member[@MemberName='ComposeAsync'][2]/Docs/*" />
/// <summary>
/// Opens the default SMS client to allow the user to send the message.
/// </summary>
/// <param name="message">A <see cref="SmsMessage"/> instance with information about the message to send.</param>
/// <returns>A <see cref="Task"/> object with the current status of the asynchronous operation.</returns>
public static Task ComposeAsync(SmsMessage? message)
=> Current.ComposeAsync(message);

static ISms Current => ApplicationModel.Communication.Sms.Default;

static ISms? defaultImplementation;

/// <summary>
/// Provides the default implementation for static usage of this API.
/// </summary>
public static ISms Default =>
defaultImplementation ??= new SmsImplementation();

Expand All @@ -52,23 +76,36 @@ public Task ComposeAsync(SmsMessage? message)
}
}

/// <include file="../../docs/Microsoft.Maui.Essentials/SmsMessage.xml" path="Type[@FullName='Microsoft.Maui.Essentials.SmsMessage']/Docs/*" />
/// <summary>
/// Represents a single SMS message.
/// </summary>
public class SmsMessage
{
/// <include file="../../docs/Microsoft.Maui.Essentials/SmsMessage.xml" path="//Member[@MemberName='.ctor'][1]/Docs/*" />
/// <summary>
/// Initializes a new instance of the <see cref="SmsMessage"/> class.
/// </summary>
public SmsMessage()
{
}

/// <include file="../../docs/Microsoft.Maui.Essentials/SmsMessage.xml" path="//Member[@MemberName='.ctor'][3]/Docs/*" />
/// <summary>
/// Initializes a new instance of the <see cref="SmsMessage"/> class.
/// </summary>
/// <param name="body">The body text that is used to prefill the composed SMS message.</param>
/// <param name="recipient">A single recipient that is added to the composed SMS message.</param>
public SmsMessage(string body, string? recipient)
{
Body = body;
if (!string.IsNullOrWhiteSpace(recipient))
Recipients.Add(recipient!);
}

/// <include file="../../docs/Microsoft.Maui.Essentials/SmsMessage.xml" path="//Member[@MemberName='.ctor'][2]/Docs/*" />
/// <summary>
/// Initializes a new instance of the <see cref="SmsMessage"/> class.
/// </summary>
/// <param name="body">The body text that is used to prefill the composed SMS message.</param>
/// <param name="recipients">A collection of recipients that are added to the composed SMS message.</param>
/// <remarks>Values in <paramref name="recipients"/> that are <see langword="null"/> or whitespace are not added as recipients.</remarks>
public SmsMessage(string body, IEnumerable<string>? recipients)
{
Body = body;
Expand All @@ -78,10 +115,14 @@ public SmsMessage(string body, IEnumerable<string>? recipients)
}
}

/// <include file="../../docs/Microsoft.Maui.Essentials/SmsMessage.xml" path="//Member[@MemberName='Body']/Docs/*" />
/// <summary>
/// Gets or sets the body of this message.
/// </summary>
public string? Body { get; set; }

/// <include file="../../docs/Microsoft.Maui.Essentials/SmsMessage.xml" path="//Member[@MemberName='Recipients']/Docs/*" />
/// <summary>
/// Gets or sets the recipients for this message.
/// </summary>
public List<string> Recipients { get; set; } = new List<string>();
}
}