title: APNS: invalid token (8)
body: <p>I am using the apns php server provided at <a href="https://code.google.com/p/apns-php/" rel="noreferrer">https://code.google.com/p/apns-php/</a>. </p>
  
  <p>I've have set up th push notification certificate but my code still throws an error on connect.</p>
  
  <p>What is wrong with this? Here is how I get the device token:</p>
  
  <pre><code>- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
  
  #if !TARGET_IPHONE_SIMULATOR
  
      // Prepare the Device Token for Registration (remove spaces and &lt; &gt;)
      NSString *deviceToken = [[[[devToken description]
                                 stringByReplacingOccurrencesOfString:@"&lt;"withString:@""]
                                stringByReplacingOccurrencesOfString:@"&gt;" withString:@""]
                               stringByReplacingOccurrencesOfString: @" " withString: @""];
      NSLog(@"%@", deviceToken);
  
  #endif
  }
  </code></pre>
  
  <p>This is the error when I run my server:</p>
  
  <pre><code>Sat, 11 May 2013 13:37:53 -0700 ApnsPHP[18198]: INFO: Trying 
  ssl://gateway.push.apple.com:2195...
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Connected to ssl://gateway.push.apple.com:2195.
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Sending messages queue, run #1: 1 message(s) left in queue.
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: STATUS: Sending message ID 1 [custom identifier: abc123] (1/3): 101 bytes.
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: ERROR: Unable to send message ID 1: Invalid token (8).
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Disconnected.
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Trying ssl://gateway.push.apple.com:2195...
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Connected to ssl://gateway.push.apple.com:2195.
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: INFO: Sending messages queue, run #2: 1 message(s) left in queue.
  Sat, 11 May 2013 13:37:54 -0700 ApnsPHP[18198]: WARNING: Message ID 1 [custom identifier: abc123] has an unrecoverable error (8), removing from queue without retrying...
  Sat, 11 May 2013 13:37:55 -0700 ApnsPHP[18198]: INFO: Disconnected.
  </code></pre>