android - Android 和 Phonegap 中的推送通知

标签 android cordova sencha-touch push-notification

我正在 Android 应用程序中搜索推送通知。我检查了“Pushwoosh”:在 initPushwoosh 方法中我看到了 GOOGLE_PROJECT_IDPUSHWOOSH_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,它是推送通知吗?

谢谢。

最佳答案

这些是您必须执行的步骤:

  1. 首先您必须在 Google API 站点注册,选择服务:https://code.google.com/apis/console/
  2. 打开 Google 云消息传递开关
  3. 在服务条款页面中,接受条款。现在您需要创建服务器 key
  4. 按“API 访问”按钮
  5. 按“创建新的服务器 key ”。服务器 key 或浏览器 key 都应该有效。使用服务器 key 的优势在于它允许您将 IP 地址列入白名单。
  6. 按“创建”。
  7. 您可以从 Google API 控制台中的 URL 找到您的 GOOGLE_PROJECT_ID。通常它看起来像这样:https://code.google.com/apis/console/#project:12345678912:access 在这个例子中,它将是:12345678912
  8. 在 Pushwoosh 面板中输入:https://cp.pushwoosh.com/
  9. 创建或进入我的应用菜单
  10. 当您进入应用程序时,您会在该页面或导航器的 url 中看到应用程序代码,这将是您的 PUSHWOOSH_APP_ID

关于android - Android 和 Phonegap 中的推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13428272/

相关文章:

javascript - 具有默认值的 SQLite 数据库

javascript - HTML5 网络应用程序中的推送通知/消息

javascript - 指示器在 loadmask sencha touch 中不起作用

android - 为 PhoneGap 应用程序嵌入 PDF 查看器

javascript - Sencha Touch 2 - 在 MVC 中添加监听器的正确方法?

Android 将 Px 转换为 Dp(视频宽高比)

android - Google Play 游戏 - 是否可以只为我的游戏过滤用户的经验值?

android - 如何以编程方式打开和显示手机的消息收件箱..?

java - 添加自定义 Lint 规则

javascript - $.mobile.showPageLoadingMsg() 不起作用