title: AWS SNS Error Invalid parameter: Token Reason: Endpoint xxx already exists with the same Token, but different attributes
body: <p>Using AWS SDK for iOS v2.0.8</p>
  
  <p>Quick question: </p>
  
  <p>How do I <code>[snsClient deleteEndpoint:request]</code>, when I do not know this endpoint's arn? I do have the deviceToken.</p>
  
  <p>Detail:</p>
  
  <p>I am receiving the error <code>Token Reason: Endpoint arn:aws:sns:...c6 already exists with the same Token, but different attributes</code> when I attempt to create an endpoint for my iPhone:</p>
  
  <pre><code>// Async call to create the platform endpoint
  [[[_awsSnsClient createPlatformEndpoint:request] continueWithSuccessBlock:^id(BFTask *task) {
      // success
      _awsPlatformEndpoint = task.result; // Save off the endpoint data
      [self awsUsubscribeAllSubscriptions];
      return nil;
  }] continueWithBlock:^id(BFTask *task) {
      if (task.error) {
          // failed with error
          ALog(@"Error: Code:%li localizedDesc:%@ Exception:%@", (long)task.error.code, task.error.localizedDescription, task.exception);
          if(task.error.code == 7) {
              // delete offending endpoint and create it again?
          }
      }
      return nil;
  }];
  </code></pre>
  
  <p>When I create the endpoint I do not set the <code>attributes</code>, I do set <code>customUserData</code> based on client data which can change. In the <a href="http://docs.aws.amazon.com/AWSiOSSDK/latest/Classes/AWSSNSCreatePlatformEndpointInput.html" rel="nofollow noreferrer">SDK docs</a> for <code>customUserData</code> it says: <em>Arbitrary user data to associate with the endpoint. Amazon SNS does not use this data. The data must be in UTF-8 format and less than 2KB.</em> </p>
  
  <p>When I delete the endpoint from the SNS console, I can get a new endpoint. So how do I deleteEndpoint, when I do not know this endpoint's arn? I can see the arn in the AWS logging, but not in the BFTask* error object.</p>
  
  <p>I've seen the ruby solution at <a href="https://stackoverflow.com/questions/19551067/how-do-i-check-whether-a-mobile-device-has-already-been-registered">19551067</a>, but I do not see a way the read the message, the ruby example reads the message from the exception, task.exception == nil in my case. I received from AWS verbose logging:</p>
  
  <p>Using AWS logging:</p>
  
  <pre><code>2014-10-01 06:48:54.489 myApp[1665:1345740] AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:244 | -[AWSXMLResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: [&lt;ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"&gt;
    &lt;Error&gt;
      &lt;Type&gt;Sender&lt;/Type&gt;
      &lt;Code&gt;InvalidParameter&lt;/Code&gt;
      &lt;Message&gt;Invalid parameter: Token Reason: Endpoint arn:aws:sns:us-west-2:245211809793:endpoint/APNS_SANDBOX/myApp-Dev/7bxxx-xxxx-xxxx-xxxc6 already exists with the same Token, but different attributes.&lt;/Message&gt;
    &lt;/Error&gt;
    &lt;RequestId&gt;d874ac10-e6de-5a4d-805e-e0b6ee58e5b7&lt;/RequestId&gt;
  &lt;/ErrorResponse&gt;
  ]
  </code></pre>
  
  <p>What I can get from (BFTask* task).error:</p>
  
  <pre><code>2014-10-01 06:48:54.494 myApp[1665:1345740] __46-[AppDelegate_Shared awsStartWithDeviceToken:]_block_invoke1279 [Line 3558] Error: 
    Code:7 
    localizedDesc:The operation couldn’t be completed. (com.amazonaws.AWSSNSErrorDomain error 7.)
    Exception:(null)
  </code></pre>
  
  <p>** Update 2014-10-01 **</p>
  
  <p>My development iPad started doing this just after updating to iOS 8.0.2. I <em>do</em> add the version number into the <code>customUserData</code> - but Amazon SNS does not use this field... right?</p>
  
  <p>** Update 2014-01-01 19:06 GMT-07:00 **</p>
  
  <p>Added <code>task.error.userInfo</code> to the error block. I'll parse the message and delete the endpoint when this comes up. An option in <code>AWSSNSCreatePlatformEndpointInput</code> to override this error, update the endpoint and return the endpoint would be nice ;)</p>
  
  <p>thank you!</p>
  
  <p>Console now has:</p>
  
  <pre><code>2014-10-01 18:58:50.836 iFlightBag[1862:1493821] __46-[AppDelegate_Shared     awsStartWithDeviceToken:]_block_invoke1281 [Line 3559] Error: 
  Code:7 
  localDesc:The operation couldn’t be completed. (com.amazonaws.AWSSNSErrorDomain error 7.) 
  Exception:(null) 
  userInfo:{
      Code = InvalidParameter;
      Message = "Invalid parameter: Token Reason: Endpoint arn:aws:sns:us-west-2:245211809793:endpoint/APNS_SANDBOX/LevelFlightMobile-Dev/7b70d2c4-846e-3afd-a1ba-eedaa00f7ac6 already exists with the same Token, but different attributes.";
      Type = Sender;
      "__text" =     (
          "\n    ",
          "\n    ",
          "\n    ",
          "\n  "
      );
  }
  </code></pre>