未找到 PushPlugin,或者不是 CDVPlugin
PushPlugin not found, or is not a CDVPlugin
我正在使用 Cordova、Angular 和 Ionic 开发应用程序。我的 phonegap 推送插件有问题,我搜索了很多但没有找到解决方案。
我使用 cordova 5.4.1 和 phonegap-plugin-push 1.5.3。当我 运行 iPad 上的应用程序或来自 Xcode 的模拟器时,日志会抛出此错误:
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 平台,但没有任何效果。
我还尝试添加 config.xml 行,例如:
<feature name="PushPlugin">
<param name="ios-package" value="PushPlugin" />
</feature>
但是不起作用。
我读过在 Xcode 的构建阶段包括 PushPlugin.m,在插件 forlder 中也包括 PushPlugin.h,但两者都已经在。我可以看到如何 Xcode正在编译插件(并生成一些警告),一切似乎都很正常,但由于某些原因它无法包含在应用程序中。
就像我说的,我浪费了很多时间搜索和尝试解决方案,但没有任何效果..
有人可以帮帮我吗?
https://github.com/phonegap-build/PushPlugin#description
Important - Push notifications are intended for real devices. They are not tested for WP8 Emulator. The registration process will fail on the iOS simulator.
但我猜它的价值是多少,请尝试 cordova plugin add phonegap-plugin-push --save
因为 phonegap/phonegap-plugin-push
是新的统一版本
我很高兴地说,两周后,我找到了解决方案!当我觉得我快疯了的时候,这个插件终于可以用了!
我以错误的(和旧的)方式初始化插件。我将初始化代码替换为:
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!
我正在使用 Cordova、Angular 和 Ionic 开发应用程序。我的 phonegap 推送插件有问题,我搜索了很多但没有找到解决方案。
我使用 cordova 5.4.1 和 phonegap-plugin-push 1.5.3。当我 运行 iPad 上的应用程序或来自 Xcode 的模拟器时,日志会抛出此错误:
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 平台,但没有任何效果。 我还尝试添加 config.xml 行,例如:
<feature name="PushPlugin">
<param name="ios-package" value="PushPlugin" />
</feature>
但是不起作用。
我读过在 Xcode 的构建阶段包括 PushPlugin.m,在插件 forlder 中也包括 PushPlugin.h,但两者都已经在。我可以看到如何 Xcode正在编译插件(并生成一些警告),一切似乎都很正常,但由于某些原因它无法包含在应用程序中。
就像我说的,我浪费了很多时间搜索和尝试解决方案,但没有任何效果.. 有人可以帮帮我吗?
https://github.com/phonegap-build/PushPlugin#description
Important - Push notifications are intended for real devices. They are not tested for WP8 Emulator. The registration process will fail on the iOS simulator.
但我猜它的价值是多少,请尝试 cordova plugin add phonegap-plugin-push --save
因为 phonegap/phonegap-plugin-push
是新的统一版本
我很高兴地说,两周后,我找到了解决方案!当我觉得我快疯了的时候,这个插件终于可以用了! 我以错误的(和旧的)方式初始化插件。我将初始化代码替换为:
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!