如何从Amazon SNS获取Subscription ARN以取消订阅

我正在使用Amazon SNS和Cognito来订阅和取消订阅某些设备的主题。

*请注意,可能有类似的话题,但亚马逊不再使用该类别。

到现在为止还挺好...

但是为了从主题中取消订阅设备,我需要传递我无法在App中弄清楚的Subscription ARN。

Subscription ARN由主题ARN(我知道)和亚马逊(我不知道)生成的字母数字字符串组成。

此代码:

AWSSNSUnsubscribeInput *input = [[AWSSNSUnsubscribeInput alloc] init];
input.subscriptionArn = @"arn:aws:sns:XXXXXXXX-YYYYYYYYYYYYYYYYYYYY-ZZZZZZZZZZZZZ";

NSLog(@"Input subscription: %@", input.subscriptionArn);

[sns unsubscribe: input completionHandler:^(NSError * _Nullable error) {
    if (error) {
        NSLog(@"Error occurred: [%ld]", error.code);
    }
    else {
        NSLog(@"Success");
    }
}];

如果我从AWS控制台获取订阅ARN,但在应用程序中无法查询或生成该字段,它工作正常。

我想这是一种散步,但到目前为止,我无法获得任何成功的方法。 我应该如何着手完成这项工作?

非常感谢你。


使用主题ARN调用[sns listSubscriptionsByTopic: input] 。 响应将包含该主题的所有订阅列表,包括订阅ARN。 您必须在响应中使用owner属性才能找到要unsubscribe的特定unsubscribe


我终于有了一些东西:

“ListSubscriptions”或“ListSubscriptionsByTopic”API操作应该返回订阅ARN:

http://docs.aws.amazon.com/sns/latest/api/API_ListSubscriptions.html http://docs.aws.amazon.com/sns/latest/api/API_ListSubscriptionsByTopic.html

链接地址: http://www.djcxy.com/p/5525.html

上一篇: How to get Subscription ARN from Amazon SNS in order to unsubscribe from it

下一篇: Notifications with Amazon SES, through Amazon SNS