繁体   English   中英

离子框架解析推送通知设备未注册

[英]ionic framework parse push notifications device not registered

我正在尝试解析推送通知以在我的android设备上工作。 我已经完成了GCM的设置,并在Urbanairship上进行了测试。 有用。 但是出于某些原因,我需要让它与解析一起运行。 我到目前为止的票价...

在我的$ionicPlatform.ready函数中,我初始化解析插件是这样的:

window.parsePlugin.initialize(
"XXX",
"XXX",
function() {
    alert( 'PARSE INIT OK' );
    window.parsePlugin.getInstallationId(function(id) {
        installationID = id;

    }, function(e) {
        console.log("Error Getting ID: " + e.code + " : " + e.message);
    })
 },
  function( e ) {
    alert( 'PARSE FAILED' );
  });
});

在我的HelloCordova.java文件中的onCreate函数中,添加了以下内容:

Parse.initialize(this, "XXX", "XXX");
PushService.setDefaultPushCallback(this, HelloCordova.class);
ParseAnalytics.trackAppOpened(getIntent());
ParseInstallation.getCurrentInstallation().saveInBackground();

我按照Parse Android的说明修改了AndroidManifest.xml 我将解析和phonegap通知插件添加到项目中。

cordova plugin add https://github.com/avivais/phonegap-parse-plugin

但是我无法注册该设备以进行解析通知。

我对此也尝试了很多次。 iOS确实可以运行,但不能正常运行。 但是在我安装了这个插件之后,它开始工作了。

https://github.com/avivais/phonegap-parse-plugin

在app.js中使用它,它确实起作用。

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
    try{
        parsePlugin.initialize('xxx', 'yyy', function() {
            alert('success');
        }, function(e) {
            alert('error');
        });

    }catch(err){
        alert('Parse Error '+err.message); //this gets executed all time
    }
  });
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM