使用 Amazon SNS 从 iOS 发送推送通知

Send push notification from iOS using Amazon SNS

我将 Amazon SNS 和 iOS 应用程序设置为通过 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 =@"hello";
message.message =@"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]);
    }];

我不知道我错过了什么。

根据 AWSInfo.m here 的调试日志,如果您没有配置 defaultCognitoCredentialsProvider

,您将收到此错误

因为他们会检查

_cognitoCredentialsProvider = [AWSInfo defaultAWSInfo].defaultCognitoCredentialsProvider;

如果他们发现 _cognitoCredentialsProvider nil 那么你会得到这个错误。

所以正确配置defaultCognitoCredentialsProvider