我正在 Android 应用程序中搜索推送通知。我检查了“Pushwoosh”:在 initPushwoosh
方法中我看到了 GOOGLE_PROJECT_ID
和 PUSHWOOSH_APP_ID
。
function initPushwoosh() {
var pushNotification = window.plugins.pushNotification;
pushNotification.registerDevice(
{
projectid: "GOOGLE_PROJECT_ID",
appid : "PUSHWOOSH_APP_ID"
},
function(status) {
var pushToken = status;
console.warn('push token: ' + pushToken);
},
function(status) {
console.warn(JSON.stringify(['failed to register ', status]));
}
);
document.addEventListener('push-notification', function(event) {
var title = event.notification.title;
var userData = event.notification.userdata;
if(typeof(userData) != "undefined") {
console.warn('user data: ' + JSON.stringify(userData));
}
navigator.notification.alert(title);
});
}
如何获得这两个ID?或者有更好的方法吗?
我在 PhoneGap 文档中看到了 Notification,它是推送通知吗?
谢谢。
最佳答案
这些是您必须执行的步骤:
- 首先您必须在 Google API 站点注册,选择服务:https://code.google.com/apis/console/
- 打开 Google 云消息传递开关
- 在服务条款页面中,接受条款。现在您需要创建服务器 key
- 按“API 访问”按钮
- 按“创建新的服务器 key ”。服务器 key 或浏览器 key 都应该有效。使用服务器 key 的优势在于它允许您将 IP 地址列入白名单。
- 按“创建”。
- 您可以从 Google API 控制台中的 URL 找到您的
GOOGLE_PROJECT_ID
。通常它看起来像这样:https://code.google.com/apis/console/#project:12345678912:access 在这个例子中,它将是:12345678912 - 在 Pushwoosh 面板中输入:https://cp.pushwoosh.com/
- 创建或进入
我的应用
菜单 - 当您进入应用程序时,您会在该页面或导航器的 url 中看到应用程序代码,这将是您的
PUSHWOOSH_APP_ID
关于android - Android 和 Phonegap 中的推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13428272/