问题
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) {});
});
回答1:
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.
来源:https://stackoverflow.com/questions/19366545/using-pusher-api-notify-particular-user