2

我有一个使用 jquery mobile 和 phonegap 的移动网络应用程序,另一个是 php 网站。我希望只向在线和移动应用程序上的特定用户发送通知,接收在 php 网站端以及移动网络应用程序上在线的用户的通知所以我的问题是如何为特定用户设置频道,因为现在通知发送给所有用户,这对消息和连接毫无用处。

目前,我的代码向所有人发送通知对于我的代码需要更改的这个问题有任何想法。

在事件触发器上,我有那个代码 php 站点。

$message = "User Response Has been Sent For Taxi On way";
            $pusher = new Pusher( APP_KEY, APP_SECRET, APP_ID );
            $data = array('message' => $message);
            $pusher->trigger( 'dispatcher_channel', 'dispatcher_Response', $data );

在移动网络应用程序上,我有该代码。

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('dispatcher_Response', function(data) {
          alert(data.message);
          channel.bind('dispatcher_Response', function(data) {});
        });
4

1 回答 1

7

尝试将用户名(我假设它对用户是唯一的)作为两端的频道名称的一部分。然后发布到该频道。

于 2013-10-14T18:22:07.923 回答