admin管理员组

文章数量:1399225

i have one mobile web app using jquery mobile and phonegap and other is php website .i want that send notification just to particular user who's online and on mobile app as well, recieve notification which user online on php website end as well as mobile web app so my question is that how to set channel for particular user because now notification sent to all users which is useless of messages and connection.

Currently my code sending notifications to all can any one idea about this problem where changes will require on my code.

on event trigger i have that code php site.

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

on mobile web app i have that Code.

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

i have one mobile web app using jquery mobile and phonegap and other is php website .i want that send notification just to particular user who's online and on mobile app as well, recieve notification which user online on php website end as well as mobile web app so my question is that how to set channel for particular user because now notification sent to all users which is useless of messages and connection.

Currently my code sending notifications to all can any one idea about this problem where changes will require on my code.

on event trigger i have that code php site.

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

on mobile web app i have that Code.

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) {});
        });
Share Improve this question asked Oct 14, 2013 at 18:17 WajihurrehmanWajihurrehman 5673 gold badges15 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Try making the username (which I assume is unique to the user) part of the channel name on both ends. Then publish to that channel.

本文标签: javascriptUsing Pusher API notify Particular UserStack Overflow