离子框架解析推送通知的设备未注册 [英] ionic framework parse push notifications device not registered
问题描述
我试图以分析推送通知到我的Android设备上运行。我也做了GCM的建立和urbanairship进行了测试。有用。
但对于一些原因,我需要得到它与解析运行。
我这样做的车费......
I'm trying to get parse push notifications to work on my android device. I have done the GCM setup and tested it with urbanairship. It works. But for some reasons I need to get it to run with parse. What I have done so fare...
在我的 $ ionicPlatform.ready
函数初始化我解析插件是这样的:
in my $ionicPlatform.ready
function I initialize the parse plugin like this:
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
我添加了这个功能:
In my HelloCordova.java
files onCreate
function I added this:
Parse.initialize(this, "XXX", "XXX");
PushService.setDefaultPushCallback(this, HelloCordova.class);
ParseAnalytics.trackAppOpened(getIntent());
ParseInstallation.getCurrentInstallation().saveInBackground();
我跟着解析Android的说明修改我的的AndroidManifest.xml
。
而我加入了parse和PhoneGap的通知插件项目。
I followed the Parse Android instructions to modify my AndroidManifest.xml
.
And I added the parse and phonegap notification plugin to the project.
cordova plugin add https://github.com/avivais/phonegap-parse-plugin
但我不能注册设备解析通知。
But I can't register the device for Parse notification.
推荐答案
我也试过这个好多次了。 iOS的没有工作,但不是机器人。但之后,我安装了这个插件,它的工作。
i also tried so many times on this. iOS did work but not android. but after i installed this plugin it worked.
https://github.com/avivais/phonegap-parse-plugin
在app.js使用这个和它的工作。
Use this in app.js and it did work.
.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
}
});
})
这篇关于离子框架解析推送通知的设备未注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!