如何使用AWS SNS从iOS App(Swift)发送短信到电话号码

时间:2017-07-08 07:52:32

标签: ios swift amazon-web-services amazon-sns

Gurus,我创建了一个ARN主题并订阅了SMS,并可以使用AWS SNS控制台向手机号码发送短信。但是,当我使用Swift尝试相同时,我不会收到短信。我错过了什么吗?这是我使用Swift发送短信的代码:

   let smsSend = AWSSNSPublishInput.init()
    smsSend?.phoneNumber = "+1408xyzabcd"// phone_number
    smsSend?.subject = "Test SMS Notification"
    smsSend?.message = message
    smsSend?.topicArn = "arn:aws:sns:us-east-1:12345:XYZ"

    var attribute_values = [String: AWSSNSMessageAttributeValue]()
    let smsType = AWSSNSMessageAttributeValue.init()
    smsType?.stringValue = "Promotional"
    smsType?.dataType = "String"

    let smsSenderID = AWSSNSMessageAttributeValue.init()
    smsSenderID?.stringValue = "xyz"
    smsSenderID?.dataType = "String"

    attribute_values.updateValue(smsType!, forKey: "AWS.SNS.SMS.SMSType")
    attribute_values.updateValue(smsSenderID!, forKey: "AWS.SNS.SMS.SenderID")
    smsSend?.messageAttributes = attribute_values
    AWSSNS.default().publish(smsSend!)

不确定我错过了什么?

0 个答案:

没有答案