title: Apple Push Notifications With Foreign Accent Characters Not Receiving
body: <p>I'm sending push notifications and when the message contains foreign characters (Turkish in my case) like İ, ş, ç, ğ... The message does not arrive to devices.  </p>
  
  <p>Here's my code:</p>
  
  <pre><code>$message = 'THİS is push';
  $passphrase = 'mypass';
  $ctx = stream_context_create();
  stream_context_set_option($ctx, 'ssl', 'local_cert', 'MyPemFile.pem');
  stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
  
  // Open a connection to the APNS server
  $fp = stream_socket_client(
      'ssl://gateway.push.apple.com:2195', $err,
      $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
  if (!$fp)
      exit("Failed to connect: $err $errstr" . PHP_EOL);
  echo 'Connected to Apple service. ' . PHP_EOL;
  
  // Encode the payload as JSON
  $body['aps'] = array(
      'alert' =&gt; $message,
      'sound' =&gt; 'default'
      );
  $payload = json_encode($body);
  
  $result = 'Start'.PHP_EOL;
  $tokenArray = array('mytoken');
  foreach ($tokenArray as $item)
  {
  // Build the binary notification
  $msg = chr(0) . pack('n', 32) . pack('H*', $item) . pack('n', strlen($payload)) . $payload;
  // Send it to the server
  $result = fwrite($fp, $msg, strlen($msg));
  if (!$result)
      echo 'Failed message'.PHP_EOL;
  else
      echo 'Successful message'.PHP_EOL;
  }
  
  // Close the connection to the server
  fclose($fp);
  </code></pre>
  
  <p>I have tried encoding $message variable with utf8_encode() but the message received as "THÝS is push". And other ways like iconv() didn't work for me, some of them cropped Turkish characters, some didn't receive at all.  </p>
  
  <p>I also have</p>
  
  <pre><code>header('content-type: text/html; charset: utf-8');
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  </code></pre>
  
  <p>in my page. I don't think the problem appears while I set the value but maybe with pack() function.  </p>
  
  <p>Any ideas to solve this without replacing characters with English?</p>