Push notification 如何使用UrbanAirship从服务器发送通知?
我试图从服务器发送一个通知,并表示要发布到/api/push/broadcast/,我已通过以下代码完成了此操作Push notification 如何使用UrbanAirship从服务器发送通知?,push-notification,urbanairship.com,Push Notification,Urbanairship.com,我试图从服务器发送一个通知,并表示要发布到/api/push/broadcast/,我已通过以下代码完成了此操作 $.ajax({ type: 'POST', dataType: 'json', url: 'https://go.urbanairship.com/api/push/?callback=?', data: '{"android": {"alert": "hi"}}', contentType: "application/json",
$.ajax({
type: 'POST',
dataType: 'json',
url: 'https://go.urbanairship.com/api/push/?callback=?',
data: '{"android": {"alert": "hi"}}',
contentType: "application/json",
username:"P4...UBg",
password:"fg...gDA",
error: function(jqXHR, textStatus, errorThrown){
// log the error to the console
alert(
"The following error occured: "+
textStatus, errorThrown
);
},
});
我得到一个500(内部服务器错误)。我按照建议添加了回调以防止“同源策略”错误。有人知道如何正确地做吗
感谢我最初尝试以这种方式(制作一个原始的$POST)设置他们的服务器。最后,我很高兴地发现,他们拥有大多数通用语言的模块。我们的服务器都是用Python编写的,所以我们使用了Python模块。以下是他们拥有的软件包列表: 我们所要做的就是将.py文件上传到我们的bin中,我们可以像这样发送推送:
airship_android = urbanairship.Airship(SECRET_KEY, MASTER_KEY)
push_data = {"android": {"alert": notification_message, "extra": str(extra_data_str)}, "apids": [apid]}
airship_android.push(push_data)
希望这有帮助 我正在使用WindowsAzure作为我的服务器,不幸的是,我需要通过JavaScript发送它