如何设置Info.Plist以使AWSSNS.defaultSNS正常工作

时间:2016-12-18 15:37:28

标签: ios amazon-web-services amazon-sns swift2.3

我正在尝试从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) 

}

1 个答案:

答案 0 :(得分:2)

没关系,我找到了解决方案。只需从PushManager复制粘贴相同的值并将PushManager更改为SNS即可。瞧,工作就像一个魅力。

相关问题