2013-07-29 4 views
0

앱을 개발했습니다. 앱이 실행되지 않을 때 번 배지 업데이트를 제외한 모든 기능이 작동합니다..iOS : Badge가 업데이트를 거부합니다 (appcelerator)

푸시 알림을 받았지만 배지에는 아무런 변화가 없습니다.

Apple에 등록 할 때 응용 프로그램에서 경고 및 배지 유형을 요청합니다.

아이디어가 있으십니까? 이것은 나를 미치게 만든다.

<?php 
$apnsHost = 'gateway.sandbox.push.apple.com'; 
$apnsCert = '/usr/local/php/cert.pem'; 
$apnsPort = 2195; 

$streamContext = stream_context_create(); 
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert); 

$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext); 

$payload['aps'] = array('alert' => 'Oh hai!', 'badge' => 1); 
$output = json_encode($payload); 
$token = '1234'; 
$token = pack('H*', str_replace(' ', '', $token)); 
$apnsMessage = chr(0) . chr(0) . chr(32) . $token . chr(0) . chr(strlen($output)) . $output; 
fwrite($apns, $apnsMessage); 

socket_close($apns); 
fclose($apns); 
+0

모바일 측 코드를 표시 할 수 있습니까? –

답변

0

  • getApplicationIconBadgeNumber() method

    푸시 및 응용 프로그램 배지를 사용하는 예입니다하지만 난 이미 말했듯이 당신도 나에게 모바일 측 코드를 표시해야 문제가 해결되지 않으면 여기에 코드가 있습니다.

    Titanium.Network.registerForPushNotifications({ 
        types: [ 
        Titanium.Network.NOTIFICATION_TYPE_BADGE, 
        Titanium.Network.NOTIFICATION_TYPE_ALERT 
        ], 
        success:function(e) 
        { 
        var deviceToken = e.deviceToken; 
        Ti.API.info("Push notification device token is: "+deviceToken); 
        alert('device token is' +e.deviceToken); 
        Ti.API.info("Push notification types: "+Titanium.Network.remoteNotificationTypes); 
        Ti.API.info("Push notification enabled: "+Titanium.Network.remoteNotificationsEnabled); 
        }, 
        error:function(e) 
        { 
        Ti.API.info("Error during registration: "+e.error); 
        }, 
        callback:function(e) 
        { 
        // called when a push notification is received. 
        //Titanium.Media.vibrate(); 
        var data = JSON.parse(e.data); 
        var badge = data.badge; 
        if(badge > 0){ 
        Titanium.UI.iPhone.appBadge = badge; 
        } 
        var message = data.message; 
        if(message != ''){ 
        var my_alert = Ti.UI.createAlertDialog({title:'', message:message}); 
        my_alert.show(); 
        } 
        } 
        }); 
    } 
    

    감사합니다.

  • +0

    앱이 꺼지면 실제로 코드가 실행됩니까? 내가 아는 한 OS는 앱이 실행되고 있지 않을 때 배지를 처리해야합니까? – grandnasty

    +0

    아니요. 코드를 실행하지 않지만 콜백 함수에서 수행합니다. –

    +0

    그렇다면 소스 코드가 중요하지 않습니까? 문제는 앱이 실행되고 있지 않을 때 배지를 업데이트하는 방법입니다. – grandnasty

    관련 문제