我正在运行用户注册时提供的推送器演示代码,但遇到问题并寻求帮助。
App Engine 中客户端是 JS,服务器代码是 Python。
我发现当我从事件创建者启动事件时,通知工作正常。
但是,当我使用示例 python 代码并从应用程序引擎启动时,我收到 2 个警报消息框:
Box1: The page at localhost:8080 says [object Object]
Box2: The page at pusher.com says [object Object]
我的Python代码:
p = pusher.Pusher(app_id='45392', key='..', secret='..')
p['test_channel'].trigger('my_event',{'message': 'hello world'})
我的Javascript代码:
var pusher = new Pusher('...');
var channel = pusher.subscribe('test_channel');
channel.bind('my_event', function(data) {
alert(data);
最佳答案
该示例完全正确,实际上您必须知道您正在发送对象,以便您可以将消息作为 data.message 超出,而不是在警报函数中传递数据。
var pusher = new Pusher('...');
var channel = pusher.subscribe('test_channel');
channel.bind('my_event', function(data) {
alert(data.message);
关于javascript - 推送通知无法按照示例中列出的那样工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16865832/