How to re-enable an Amazon SNS endpoint with the iOS SDK?

amazon-sns, amazon-web-services, ios, push-notification

Solution

There are some conditions which I have found so far in which endPoint attributes gets false even though endpoints and tokens are correct

If you have created the amazon sns app with Production APNS certificate but you try to register your device with SANDBOX APNS i.e. Development APNS then it will get false

When user turns off notifications in Phone Settings then apple APNS disables the flag which affects in amazon sns too. whenever user enables the notification again you have resend the token to amazon to setattribute true i.e. need to handle on client side

When user removes/unistalls the app

Problem

I'm using Amazon SNS to send push notifications to my iOS app. For whatever reason, my endpoints occasionally seem to get set to "false" - even though I know that they are valid endpoints (because re-enabling them then delivers new push notifications to the device). There's a similar Stack Overflow question here - but no technical answer as to how to resolve the issue. So: I need to figure out how to set the endpoint as `enabled`. There's only sparse Amazon documentation for how to do this, so what I do know is that I need to use the "enabled" key/value in the attributes dictionary. My snippet of code looks like this: ``` AmazonSNSClient *sns = [AmazonClientManager sns]; SNSCreatePlatformEndpointRequest *endpointPutRequest = [SNSCreatePlatformEndpointRequest new]; endpointPutRequest.platformApplicationArn = kBXTAWSAppARN; endpointPutRequest.token = deviceToken; [endpointPutRequest setAttributesValue:@"True" forKey:@"Enabled"]; SNSCreatePlatformEndpointResponse *endpointResponse = [sns createPlatformEndpoint:endpointPutRequest]; ``` This works perfectly, except for a single line of code, which sets the attributesValue "Enabled" to "true". I've tried all of these combinations: ``` [endpointPutRequest setAttributesValue:@"true" forKey:@"Enabled"]; [endpointPutRequest setAttributesValue:@"true" forKey:@"enabled"]; [endpointPutRequest setAttributesValue:@"True" forKey:@"Enabled"]; ``` ...yet none of them work. What is the proper way to write this line of code? Should I be using a BOOL somehow? An integer?

Original source

Related problems