问题描述
我正在使用Cordova,Angular和Ionic开发一个应用程序。我有一个问题与phonegap push插件,我搜索了很多,但没有找到解决方案。
I am developing an app using Cordova, Angular and Ionic. I have a problem with the phonegap push plugin and I've searched a lot but no solutions found.
我使用cordova 5.4.1和phonegap-plugin-push 1.5。 3。当我在iPad上运行应用程序或从Xcode运行仿真器时,日志会抛出此错误:
I use cordova 5.4.1 and phonegap-plugin-push 1.5.3. When I run the app on iPad or emulator from Xcode, logs throws this error:
ERROR: Plugin 'PushPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
[CDVCommandQueue executePending] [Line 159] FAILED pluginJSON = [
"PushPlugin938856013",
"PushPlugin",
"register",
[{
"ecb":"onNotificationAPN",
"alert":"true",
"badge":"true",
"sound":"true"
}]
]
我已重新安装插件多次,删除/添加ios平台,没有什么工作。
I`ve还尝试在config.xml行中添加:
I've reinstalled the plugin several times, removing/ adding the ios platform, and nothing works.I`ve also tried adding on config.xml lines like:
<feature name="PushPlugin">
<param name="ios-package" value="PushPlugin" />
</feature>
但不起作用。
我读过包括PushPlugin.m在Xcode和PushPlugin.h在插件forlder的构建阶段,但两个alredy。我可以看到Xcode如何编译插件(并产生一些警告),一切似乎正常,但对于一些原因,它不能包括在应用程序。
I've read for including PushPlugin.m in build phases on Xcode and PushPlugin.h in plugin forlder too, but both alredy in. I can see how Xcode is compiling the plugin (and generating some warnings ), everything seems normal, but for some reason it can't be included on the app.
像我说的,我浪费了很多时间搜索和尝试解决方案,但没有什么作品。 。
任何人可以帮助我吗?
Like I've said, I've wasted a lot of time searching and trying solutions, but nothing works.. Could anybody help me, please?
推荐答案
我很高兴地说,两个星期后,找到了解决方案!当我想我变得疯狂,插件终于工作了!
我以错误(和旧)的方式初始化插件。我用以下代码替换了我的初始化代码:
I'm happy to say that, after two weeks, I've found the solution! When I thought I'm getting crazy, the plugin finally works! I was initializing the plugin by the wrong (and old) way. I replaced my init code with:
var pushNotification = PushNotification.init({
"android": {
"senderID": "1234567890"
},
"ios": {"alert": "true", "badge": "true", "sound": "true"},
"windows": {}
});
pushNotification.on('registration', function(data) {
console.log("registration event");
console.log(JSON.stringify(data));
});
pushNotification.on('notification', function(data) {
console.log("notification event");
console.log(JSON.stringify(data));
pushNotification.finish(function () {
console.log('finish successfully called');
});
});
pushNotification.on('error', function(e) {
console.log("push error");
});
非常感谢您的帮助,@Dwardu!
And it works!Many thanks for you help, @Dwardu!
这篇关于找不到PushPlugin,或者不是CDVPlugin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!