0

私は通知にPusher APIを使用していますが、それは私のために働いています。Web サイトにコンボボックスがあり、このコンボ ボックスで azure にデプロイされています。ユーザーがコンボ ボックスのステータスを変更すると、保留中の完全な requesttimeout を示す 3 つのステータスが表示されるため、ajax リクエストは、チャネルとイベント バインドを追加した json ファイルに送信されます。

エミュレーターでもメッセージを受信して​​います

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 これは azure にあります

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);
    }

そして、私がAndroidで使用している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>
4

1 に答える 1

0

ログは、あなたが接続され、dispatcher_channelチャンネルに登録されていることを示しています。

を実行すると、Pusher Debug Console には何が表示されますjson.phpか? 参照: http://pusher.com/docs/debugging#pusher_debug_console

json.phpPusherに届いたメッセージは表示されていますか?

そうでない場合は、PHP コードのデバッグを検討する必要があります。参照: https://github.com/pusher/pusher-php-server#debugging

上記のように、クライアント側の機能は期待どおりに機能しているようです。

于 2013-10-13T19:19:46.813 に答える