gpt4 book ai didi

ios - 角标(Badge)推送增量仅适用于 xcode

转载 作者:行者123 更新时间:2023-11-29 02:28:02 26 4
gpt4 key购买 nike

角标(Badge)推送增量仅在我的设备在 xcode 中运行时才起作用,但是当我拔下它时,只能收到带有声音的推送通知,正确提醒,但增量角标(Badge)不会出现在应用程序图标中。有人知道这个吗?

提前致谢。

最佳答案

抱歉,这是我的 php 脚本,它与我的终端 osx 一起运行。

$deviceToken = '3d51...';
$tokenIpad = '3bf2a..';


// Put your private key's passphrase here: // Second pass wich has been created
$passphrase = '37...';

// Put your alert message here:
$message = 'Hello!';
$badge = '1';

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

// Open a connection to the APNS server
$fp = stream_socket_client(
'ssl://gateway.sandbox.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 APNS' . PHP_EOL;

// Create the payload body
$body = array(
'aps' => array(
"content-available" => "1",
"alert" => $message,
"badge" => $badge,
"sound" => 'default'
)
);

// Encode the payload as JSON
$payload = json_encode($body);

// Add device tokens
$tokens = array(
$deviceToken,
//$tokenIpad
);

foreach ($tokens as $value)
{
$msg = chr(0) . pack('n', 32) . pack('H*', $value) . pack('n', strlen($payload)) . $payload;
$result = fwrite($fp, $msg, strlen($msg));

if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered' . PHP_EOL;
}

// Close the connection to the server
fclose($fp);

关于ios - 角标(Badge)推送增量仅适用于 xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27255169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com