2016-12-01 153 views
0

我設置了Amazon SNS和iOS應用程序,通過SNS控制檯發送推送通知並在iOS中接收。它正常工作。使用Amazon SNS從iOS發送推送通知

現在,我想從一個設備發送推送通知到另一臺設備,但我發現了以下錯誤:

-[AWSServiceInfo initWithInfoDictionary:checkRegion:] | Couldn't read credentials provider configurations from Info.plist . Please check your Info.plist if you are providing the SDK configuration values through Info.plist .

有我的代碼發送推送通知

AWSSNS *publishCall = [AWSSNS defaultSNS]; 

AWSSNSPublishInput *message = [AWSSNSPublishInput new]; 

message.subject = @"My First Message"; 


//This is the ending point 
message.targetArn = @"arn:aws:sns:us-west-2:895047407854:endpoint/APNS_SANDBOX/XXXXX/XXXX-XXXX-XXX-XXXX"; 
message.subject [email protected]"hello"; 
message.message [email protected]"teste from device"; 
// message.messageAttributes = messageDict; 
// 
// message.messageStructure = jsonString; 

    [publishCall publish:message completionHandler:^(AWSSNSPublishResponse * _Nullable response, NSError * _Nullable error) { 
     if(error) NSLog(@"%@", [error userInfo]); 
     if(response) NSLog(@"%@", [response description]); 
    }]; 

我不知道我在想什麼。

回答

1

爲每AWSInfo.mhere調試日誌,當你還沒有配置您的defaultCognitoCredentialsProvider

你會得到這個錯誤,因爲他們將檢查

_cognitoCredentialsProvider = [AWSInfo defaultAWSInfo].defaultCognitoCredentialsProvider; 

,如果他們發現_cognitoCredentialsProvider零,那麼你會得到這個錯誤。

因此正確配置defaultCognitoCredentialsProvider

+0

現在錯誤更改爲無權執行:SNS:在資源上發佈:arn:aws:sns:us-west-2:XXXXXXXXXX:app/APNS_SANDBOX/XXXXXX <' – sdadsad

+0

該錯誤表示您無法執行執行此操作,您需要檢查您的權限 – Rajat

+0

我在哪裏可以檢查我的權限? – sdadsad