尝试从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。瞧,作品就像魅力。

09-26 10:17