如何设置 Info.Plist 以获得 AWSSNS.defaultSNS 工作

How to set Info.Plist to get AWSSNS.defaultSNS work

我在尝试从 AWSSNS 获取 defaultSNS 时遇到错误。它说:

'NSInternalInconsistencyException', reason: 'The service configuration
is `nil`. You need to configure `Info.plist` or set `defaultServiceConfiguration` 
before using this method.'

我正在处理从 MobileHub 集成页面下载的示例文件,我的代码位于 PushNotificationViewController 中。如下:

override func viewDidLoad() {
    super.viewDidLoad()
    let pushManager: AWSPushManager = AWSPushManager.defaultPushManager()
    pushManager.delegate = self
    pushManager.registerForPushNotifications()
    pushNotificationSwitch.on = pushManager.enabled
    if let topicARNs = pushManager.topicARNs {
        pushManager.registerTopicARNs(topicARNs)
    }

    let someDict:[String:String] = ["CustomUserData":"This is test data"]
    var attr = AWSSNSSetEndpointAttributesInput()
    attr.attributes = someDict
    attr.endpointArn = "arn:aws:sns:xxxxxxxx"
    let defSns = AWSSNS.defaultSNS() <-- Error is here
    defSns.setEndpointAttributes(attr) 

}

没关系,我找到了解决方案。只需从 PushManager 复制粘贴相同的值并将 PushManager 更改为 SNS。瞧,很有魅力。