2013-10-12 3 views
0

나는 통보를 위해 푸서 API를 사용하고 있지만 나를 위해 노력하고 있습니다. 나는이 웹 사이트에 콤보 상자가 있습니다.이 콤보 상자에는 하늘색에 배치 된 콤보 상자가 있습니다. 사용자가 콤보 상자에서 상태를 변경하면 보류중인 전체 요청 시간이 표시되는 3 가지 상태입니다. 아약스 요청은 채널 및 이벤트 바인드를 추가 한 json 파일로 전송됩니다.푸시 api 통지 안드로이드 에뮬레이터뿐만 아니라 브라우저에서 작동하지 않습니다

나는 또한 에뮬레이터에서

10-12 12:13:15.544: D/CordovaLog(1257): file:///android_asset/www/index.html: Line 28 : Pusher : State changed : unavailable -> connected 
10-12 12:13:15.544: I/Web Console(1257): Pusher : State changed : unavailable -> connected at file:///android_asset/www/index.html:28 
10-12 12:13:15.553: D/CordovaLog(1257): file:///android_asset/www/index.html: Line 28 : Pusher : Event sent : {"event":"pusher:subscribe","data":{"channel":"dispatcher_channel"}} 
10-12 12:13:15.553: I/Web Console(1257): Pusher : Event sent : {"event":"pusher:subscribe","data":{"channel":"dispatcher_channel"}} at file:///android_asset/www/index.html:28 
10-12 12:13:17.613: D/CordovaLog(1257): file:///android_asset/www/index.html: Line 28 : Pusher : Event recd : {"event":"pusher_internal:subscription_succeeded","data":{},"channel":"dispatcher_channel"} 
10-12 12:13:17.613: I/Web Console(1257): Pusher : Event recd : {"event":"pusher_internal:subscription_succeeded","data":{},"channel":"dispatcher_channel"} at file:///android_asset/www/index.html:28 
10-12 12:13:17.623: D/CordovaLog(1257): file:///android_asset/www/index.html: Line 28 : Pusher : No callbacks on dispatcher_channel for pusher:subscription_succeeded 
10-12 12:13:17.623: I/Web Console(1257): Pusher : No callbacks on dispatcher_channel for pusher:subscription_succeeded at file:///android_asset/www/index.html:28 

json.php을 MSG를 수신하고이 푸른

function updateRequestStatus($params) 
    { 
     global $api; 

     $params = json_decode($params, true); 

     $requestStatus = PageHelper::sanitizeInput($params['requestStatus'], FILTER_SANITIZE_STRING); 
     $requestID = PageHelper::sanitizeInput($params['requestID'], FILTER_SANITIZE_NUMBER_INT); 

     if(strtolower($requestStatus) == "completed") 
     { 
      $message = "User Response Has been Sent "; 
      $pusher = new Pusher(APP_KEY, APP_SECRET, APP_ID); 
      $data = array('message' => $message); 
      $pusher->trigger('dispatcher_channel', 'dispatcher_Response', $data); 
     } 

     return $api->updateRequestStatus($requestStatus, $requestID); 
    } 

과 내가 안드로이드에 사용하고 index.html을에 있습니다.

<!DOCTYPE HTML> 
<html> 
<head> 
<title></title> 

<meta name="viewport" content="width=device-width,initial-scale=1"/> 

<!-- JavaScript --> 


<script src="http://js.pusher.com/2.1/pusher.min.js" type="text/javascript"></script> 
<script src="js/cordova.js" type="text/javascript"></script> 

<script type="text/javascript"> 
    // Enable pusher logging - don't include this in production 
    Pusher.log = function(message) { 
     if (window.console && window.console.log) { 
     window.console.log(message); 
     } 
    }; 

    var pusher = new Pusher('APP_KEY'); 
    var channel = pusher.subscribe('dispatcher_channel'); 
    channel.bind('notification', function(data) { 
    setTimeout('getNotification()', 1000); 
    channel.bind('dispatcher_Response', function(data) {}); 
    }); 
    function getNotification() 
    { 
     navigator.notification.alert("status changed", function() {}); 
    } 
    </script> 

</head> 
</body> 
</html> 

답변

0

로그에 연결되어 있고 dispatcher_channel 채널에 가입되어있는 것으로 나타납니다.

json.php을 실행할 때 푸시 디버그 콘솔에 표시되는 내용은 무엇입니까? 참조 : http://pusher.com/docs/debugging#pusher_debug_console

json.php의 메시지가 푸셔에 표시됩니까?

그렇지 않다면 PHP 코드를 디버깅해야합니다. 참조 : https://github.com/pusher/pusher-php-server#debugging

위와 같이 클라이언트 쪽 기능이 예상대로 작동하는 것 같습니다.

+0

문제가 PHP 코드에서 문제가 해결되었습니다. – Wajihurrehman

+0

알림 메시지가 표시되지 않는 이유를 알 수 있습니다. 내 안드로이드 에뮬레이터의 고양이 로그를 확인했습니다. 메시지가 나타나지만 에뮬레이터에서 팝업되지 않습니다. – Wajihurrehman

+0

위 코드에서 ('channel.bind ('dispatcher_Response ', 데이터) {});) 이벤트 데이터로 아무 것도하지 않습니다. – leggetter