【问题标题】:Push notification in Android and PhonegapAndroid 和 Phonegap 中的推送通知
【发布时间】:2012-11-17 06:22:21
【问题描述】:

我正在 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 文档中看到了通知,是推送通知吗?

谢谢。

【问题讨论】:

    标签: android cordova sencha-touch push-notification


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      Phonegap 的 Notification 与推送通知无关。在这里查看:http://docs.phonegap.com/en/2.2.0/cordova_notification_notification.md.html#Notification

      要将 Pushwoosh for Android 与 Phonegap 集成,请查看手册:http://www.pushwoosh.com/programming-push-notification/android-gcm-push-notifications-guide/

      此页面上有更多使用 Pushwoosh 的指南:
      http://www.pushwoosh.com/programming-push-notification/

      祝你好运!

      【讨论】:

      • 谢谢,pushwoosh远程api有什么用?因为我无法使用免费帐户访问它
      • 没错,你至少要有一个高级账户:pushwoosh.com/accounts-comparison 使用远程api你可以通过远程api请求发送自定义数据,例如您可以向特定设备发送通知。祝你好运!
      • 推送通知有开源的吗?
      • 没有远程api可以发送推送通知吗?,我不明白有api和没有api有什么区别
      • 可以,但您必须自己编写和发送。就像在这个屏幕截图中一样:pushwoosh.com/wp-content/uploads/2011/06/… 使用远程 api,您可以在您的服务器上安排它。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多