i\'ve done a apple-mdm-ota-server for IOS so far. The devices deliver me following things to the server (in form of a plist/xml):
-Push Magic Token -Device Token (in b64
use this libray
function push_device($data) {
$push = new ApnsPHP_Push(
ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION,
'../MyPushCert.pem'
);
$push->connect();
$message = new ApnsPHP_Message_Custom($data["Token"]);
$message->setCustomProperty('mdm', $data["PushMagic"]);
$push->add($message);
$push->send();
$push->disconnect();
}
I did not see that you included your APNS key when setting up the stream. Here is (roughly) what we do:
$apns_certkey_path = '/path/to/cert/and/key/file' ;
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apns_certkey_path);
$apns = stream_socket_client(
'ssl://' . $apns_url . ':' . $apns_port,
$error,
$errorString,
2, // timeout
STREAM_CLIENT_CONNECT,
$streamContext
);
$payload = json_encode(array('mdm' => $PushMagic));
$apnsMessage = chr(0) . chr(0)
. chr(32) . base64_decode($ApnsTokenB64)
. chr(0) . chr(strlen($payload)) . $payload;
fwrite($apns, $apnsMessage);