不工作 AWS SNS 在 C# 中使用 AWS SDK 发送短信

Not working AWS SNS Sending Text messages using AWS SDK in C#

我已经在示例应用程序中使用 AWS - Amazon Simple Notification Service NuGet 包成功发送了文本消息。 (在这个Package中,会自动安装AWSSDK- Core 运行次) 但是,当我试图在我当前的项目中合并代码时,我们已经将 AWS SDK 用于其他亚马逊服务,我没有得到发送短信所需的 属性 之一。

为了发送短信,我们需要创建发布请求对象并将该对象传递给 AmazonSimpleNotificationServiceClient。

请查找以下代码

AmazonSimpleNotificationServiceClient smsClient = new AmazonSimpleNotificationServiceClient("Access Key", "Secret Access Key", Region);

PublishRequest publishRequest = new PublishRequest();
publishRequest.Message = message;
publishRequest.MessageAttributes = smsAttributes; 
publishRequest.PhoneNumber = "Phone number to which need to send text message";

然后,我们需要将这个对象传递给SNS

PublishResponse result = smsClient.Publish(publishRequest);

但我在当前项目中没有得到 "PhoneNumber" 属性,它引用了最新更新的 AWS SDK(在我的项目中安装了 NuGEt 包 - AWS SDK for .NET 的最新版本)。

如果我尝试安装较早的 NuGEt 包并成功 运行 代码,我会遇到冲突,因为我在两个 dll 中得到 class "AmazonSimpleNotificationServiceClient" 即。核心和 AWSSDK。

求推荐。

PhoneNumber 仍在最新版本的 SDK 中。不知何故,在您合并其他代码后,它会诱使您的构建系统包含旧版本。 AWSSDK.SimpleNotificationService 包的 3.1.1 版添加了 PhoneNumber。

您是否向已经依赖 SDK 的项目添加了新的依赖项?