【问题标题】:ionic and $cordovaPush离子和 $cordovaPush
【发布时间】:2016-02-27 16:05:14
【问题描述】:

我是新来的:D

我有下一个代码:

alert('hi');
$cordovaPush.register(config).then(function (result) {
  alert('push' + result);
}, function (err) {
   alert('error);
});
alert('bye');

当我转到 Ionic View 时,我会收到警报:“hi”和“bye”,但从来没有“push”或“error”...

我安装:

ionic plugin add https://github.com/phonegap-build/PushPlugin

然后我将 ng-cordova.js 和 PushNotification.js 放入索引中...

发生了什么?

谢谢!

【问题讨论】:

    标签: cordova ionic-framework push


    【解决方案1】:

    我认为你的代码不对

    像这样检查错误

    alert('hi');
    $cordovaPush.register(config)
    
    .then(function (result) {
      alert('push' + result);
    })
    
    .fail(function (err){
      alert(err);
    })
    
    alert('bye');
    

    【讨论】:

      【解决方案2】:

      查看ngCordova 插件对您来说很容易。 例如:

       var androidConfig = {
              "senderID": "xxxxxxxxxxxx",
          };
      $ionicPlatform.ready(function() {
         $cordovaPush.register(androidConfig).then(function(result) {
                  console.log(result);
              }, function(err) {
                  console.log(err);
              })
         });
      

      app.js 文件中添加的上述代码。祝你好运。

      【讨论】:

      • 我查看 ngcordova.com/docs/plugins/pushNotifications 并复制粘贴并得到相同的结果...
      • 没什么,我试了又试,一无所获。我得到 Ripple,它说“PushNotification 未定义”......也许 deviceready 不起作用:s
      • 是的,正在工作。我得到“PushNotification ... init”后得到“PushNotification 未定义”。所以,我猜我的 deviceready 有问题
      • 这对我有用,您的发件人是否正确? ,以及用于测试的设备。
      • 我正在尝试使用 iosConfig(与 Cordova 页相同),我使用 Ionic View、Browser、Ripple、iOS Emulate 和 Run 进行了测试......什么也没有
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-19
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      • 1970-01-01
      • 2017-06-20
      • 1970-01-01
      相关资源
      最近更新 更多