1
我有使用jQuery Mobile和PhoneGap的等一个移动网络应用程序是PHP的网站。我想,关于发送通知网上只是为了谁在线和移动应用程序,以及特定的用户,收到通知该用户PHP的网站结束以及移动的网络应用程序,所以我的问题是,如何为特定用户设置频道,因为现在通知发送给所有用户,这是没有用的消息和连接。使用推API通知特定用户
目前我的代码发送通知到所有能对这个问题的任何一个知道在哪里的变化将需要我的代码。
事件触发我有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);
在移动web应用程序我有该代码。
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) {});
});
维迪亚没有ü意味着,而不是使用我的代码pusher.subscribe(“dispatcher_channel”);现在从 替换的用户名的两端像 VAR的用户名=“阿里”; VAR信道= pusher.subscribe(用户名); – Wajihurrehman
有点像var channel = pusher.subscribe(“channel_”+ username); – Vidya
根据http://stackoverflow.com/a/19197310/39904,这是正确的答案,目前是实现用户特定通知的唯一方法。 – leggetter