iOS 推送通知本地化无效

iOS push notification localization not working

我正在尝试构建 iOS 支持本地化的推送通知服务器。 我将消息字符串添加到我的 ios 项目到我的本地化并使用 NSLocalizedString.

检查它

我正在使用这个代码:

<?PHP

if(isset($_GET['message']) && isset($_GET['sender']) ){
$deviceToken="5cca98f1 4e20c5e4 5267d4da 23437439 81959bd0 b75b7573 42a2f9d7 ceed8f0f";
$message = stripslashes($_GET['message']);
$sender = stripslashes($_GET['sender']);

$payload = '{
    "aps":{
        "alert":{
            "loc-key":"'.$message.'",
            "loc-args":["'.$sender.'"]
        },
        "badge":1,
        "sound":"bingbong.aiff"
    }
}';
print $payload;

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'password');
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if(!$fp){
    print "Failed to connect $err $errstrn";
    return;
} else {
    print "Notifications sent!";
}

$devArray = array();
array_push($devArray,$deviceToken);

foreach($devArray as $deviceToken){
    $msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack        ("n",strlen($payload)) . $payload;
    $result = fwrite($fp, $msg, strlen($msg));
}
fclose($fp);
print "This is the Device Token Sent Each Time".strlen($msg)."\n";
}

但是没有通知发送到设备。 当我尝试不进行本地化并使用此有效负载发送消息时:

$payload = '{
    "aps":{
        "alert":"'.$message.'",
        "badge":1,
        "sound":"bingbong.aiff"
    }
}';

设备收到通知。

我用的是苹果的this link

我做错了什么?

看来你不见了, 固定码:

$payload = '{
                "aps" : 

                    { 
                        "alert" :{
                                     "loc-key":"'.$message.'",
                                     "loc-args":["'.$sender.'"]
                                },//<=================
                          "badge" : 1,
                          "sound" : "bingbong.aiff"
                    } 
            }';