Ios 徽章推送增量仅在xcode中有效

Ios 徽章推送增量仅在xcode中有效,ios,objective-c,apple-push-notifications,Ios,Objective C,Apple Push Notifications,Badge push increment仅在我的设备在xcode中运行时起作用,但当我拔下它时,它只接收到带有声音的推送通知,并正确发出警报,但增量Badge不会出现在应用程序图标中。 有人知道这件事吗 提前感谢。这是我在AppDelegate中的代码: -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandl

Badge push increment仅在我的设备在xcode中运行时起作用,但当我拔下它时,它只接收到带有声音的推送通知,并正确发出警报,但增量Badge不会出现在应用程序图标中。 有人知道这件事吗


提前感谢。

这是我在AppDelegate中的代码:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{ NSLog(@“Test%@”,userInfo)

}
再次感谢。

对不起,这是我的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);

演示如何设置并在代码中递增它?
$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);