[英]ionic framework parse push notifications device not registered
I'm trying to get parse push notifications to work on my android device. 我正在尝试解析推送通知以在我的android设备上工作。 I have done the GCM setup and tested it with urbanairship.
我已经完成了GCM的设置,并在Urbanairship上进行了测试。 It works.
有用。 But for some reasons I need to get it to run with parse.
但是出于某些原因,我需要让它与解析一起运行。 What I have done so fare...
我到目前为止的票价...
in my $ionicPlatform.ready
function I initialize the parse plugin like this: 在我的
$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' );
});
});
In my HelloCordova.java
files onCreate
function I added this: 在我的
HelloCordova.java
文件中的onCreate
函数中,添加了以下内容:
Parse.initialize(this, "XXX", "XXX");
PushService.setDefaultPushCallback(this, HelloCordova.class);
ParseAnalytics.trackAppOpened(getIntent());
ParseInstallation.getCurrentInstallation().saveInBackground();
I followed the Parse Android instructions to modify my AndroidManifest.xml
. 我按照Parse Android的说明修改了
AndroidManifest.xml
。 And I added the parse and phonegap notification plugin to the project. 我将解析和phonegap通知插件添加到项目中。
cordova plugin add https://github.com/avivais/phonegap-parse-plugin
But I can't register the device for Parse notification. 但是我无法注册该设备以进行解析通知。
i also tried so many times on this. 我对此也尝试了很多次。 iOS did work but not android.
iOS确实可以运行,但不能正常运行。 but after i installed this plugin it worked.
但是在我安装了这个插件之后,它开始工作了。
https://github.com/avivais/phonegap-parse-plugin
Use this in app.js and it did work. 在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.