我有一个使用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) {});
});
尝试将用户名(我假设对用户来说是唯一的)作为两端通道名称的一部分。然后发布到该频道。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)