我正在使用 phonegap-plugin-push 和 GCM 来进行 iOS 和 Android 的推送通知。在过去的三周中,一切都很正常,但突然间就无法正常工作了。我只能收到大约发送消息的 1/20。
我正在使用 GCM 的主题消息功能。当我发送消息时,我会收到成功的响应。
Object {message_id: <MESSAGE_ID>}
但是我似乎很少收到这个消息。
如果我直接向设备(注册令牌)发送消息,那么消息会被正确地接收。
我已经使用jQuery ajax请求和C#后端请求进行了测试。两者的结果都是一样的。
我的jQuery测试脚本:
$.ajax({
url: "https://gcm-http.googleapis.com/gcm/send",
type: "POST",
dataType: "json",
crossDomain: true,
headers: {
"Authorization": "key=<AUTH_KEY>",
"Content-type": 'application/json'
},
data: JSON.stringify({
to: "/topics/" + topics,
priority: 'high',
content_available: true,
notification: {
body: msg,
title: "Test",
sound: "bubble.wav"
},
data: {
soundname: "bubble.wav",
test: "test"
}
})
}).done(function (attr) {
console.log('done');
console.log(attr);
}).error(function (err) {
console.log('err');
console.log(err);
});
在Android和iOS上进行了测试。两者结果相同。