简体   繁体   English

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

[英]How to set Info.Plist to get AWSSNS.defaultSNS work

I'm getting an error while I'm trying to get defaultSNS from AWSSNS. 尝试从AWSSNS获取defaultSNS时出现错误。 It says : 它说 :

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

I'm working on a sample file downloaded from MobileHub integration page, and my code is placed inside PushNotificationViewController. 我正在研究从MobileHub集成页面下载的示例文件,我的代码位于PushNotificationViewController中。 It is as below : 如下:

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) 

}

Nevermind, I found the solution. 没关系,我找到了解决方案。 Just copy paste the same values from PushManager and changed PushManager to SNS. 只需从PushManager复制粘贴相同的值,然后将PushManager更改为SNS。 Voila, works like a charm. 瞧,作品就像魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM