【发布时间】:2018-05-16 16:48:20
【问题描述】:
我已按照此处的说明进行操作。 (https://documentation.onesignal.com/v3.0/docs/phonegap-sdk-setup)
我的目标是将推送通知从服务器(Firebase 或 OneSignal)发送到我正在 Chrome 浏览器或 PhoneGap 测试应用程序上测试的 Android 设备。
我已将以下代码添加到我的 onDeviceReady 函数并运行;
console.log("OneSignal is here!");
var notificationOpenedCallback = function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
alert("Received my notification");
};
// c02be63f-e777-4b99-8775-dec62efxxxxx is my APP ID
window.plugins.OneSignal
.startInit("c02be63f-e777-4b99-8775-dec62efxxxxx")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
window.plugins.OneSignal.setSubscription (true);
window.plugins.OneSignal.enableNotificationWhenActive(true);
但是,运行后,我收到以下错误。有人可以解释一下这个错误是什么意思吗?
Error: exec proxy not found for :: StatusBar :: _ready
(index):365 OneSignal is here!
(index):365 Error: exec proxy not found for :: OneSignalPush :: setNotificationReceivedHandler
(index):365 Error: exec proxy not found for :: OneSignalPush :: setNotificationOpenedHandler
(index):365 Error: exec proxy not found for :: OneSignalPush :: init
(index):365 Error: exec proxy not found for :: OneSignalPush :: setSubscription
我注意到我尝试过的所有其他新插件都有同样的错误。这意味着有问题。
这是我的config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.upen.testing" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Testing</name>
<description>
A blank PhoneGap app.
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<content src="index.html" />
<access origin="*" />
<gap:plugin name="onesignal-cordova-plugin" source="npm" spec="^2.2.4" />
<preference name="phonegap-version" value="cli-7.1.1" />
<preference name="android-build-tool" value="gradle" />
<preference name="android-minSdkVersion" value="15" />
<engine name="browser" spec="~5.0.1" />
<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
<plugin name="onesignal-cordova-plugin" spec="~2.2.4" />
<plugin name="cordova-plugin-statusbar" spec="~2.3.0" />
<plugin name="cordova-plugin-fcm" spec="^2.1.2" />
<engine name="android" spec="~6.3.0" />
</widget>
【问题讨论】:
-
查看我的answer 快速指南 Cordova 安装。
-
我已经安装了 Cordova/PhoneGap/Node.js - 一切正常。除了在测试项目中加载的插件会得到这个 exec... 错误。
-
我认为问题出在
上。尝试下载和使用 -
你的 index.html 中有链接的 cordova.js 吗?
-
是的,cordova.js 已链接。
标签: android cordova firebase phonegap-plugins onesignal