Project need, has recently spent some time learning the AWS SNS, wrote a Demo on ios, is after the program up, creating the Endpoint, then go to subscribe to a prior in SNS background to create a good Topic, all ready, call AmazonSNSClient the subscribe method to subscribe to the Topic, until the call is normal, see the subscribe method, after calling the method mentioned in the document to invoke confirmSubscription confirm subscription:
But when the call confirmSubscription method, an exception, wrong mean Token:
From the code to the device before and after the same token, why there are abnormal, or the token here I understand is wrong, in this case, the token is not device token?
More strange is that although the program in the last step throw exceptions, but SNS console can see create the Endpoint, and subscription is successful, the SNS console push messages can also receive,
The return value is the subscribe method of SNSSubscribeResponse, has examined the SNSSubscribeResponse document description, here have a subscriptionArn attributes, from the perspective of the instructions of this property, seemed not to call after call the subscribe method confirmSubscription:
Finally summed up the problem:
1, the subscribe method statement made clear that this method is invoked after confirmation must call confirmSubscription method;
2, call confirmSubscription method, pass the token of the same as the token of invoking the subscribe (all device token), abnormal program, is probably said token is wrong;
3, the second problem happened, but social background of the endpoint to create success, success and also subscribe to the Topic, and normal push function;
4, discovered by the third question, do not call confirmSubscription can achieve a goal;
5, from the subscribe method return values of SNSSubscribeResponse found that call behind might not need to call the subscribe confirmSubscription,
Although the push function to achieve, but the problem still do not understand, to solve!