2

I have followed the instructions here to the dot. (https://documentation.onesignal.com/v3.0/docs/phonegap-sdk-setup)

My goal is to send Push Notifications from a server (Firebase or OneSignal) to my Android device which I am testing on Chrome browser or PhoneGap test app.

I have added the following code to my onDeviceReady function and it runs;

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);

However, after running, I get the following errors. Can someone please explain what this error means?

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

I have noticed the same error for every other new plugin I tried. This means something is wrong.

Here is my 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>
LuckyStarr
  • 1,468
  • 2
  • 26
  • 39
Zac
  • 695
  • 1
  • 11
  • 34
  • see my [answer](https://stackoverflow.com/questions/39066959/check-internet-connection-in-android-webview-cordova/39211383#39211383) a Quick Guide Cordova installation. – Jon Goodwin Dec 04 '17 at 23:24
  • I've installed Cordova/PhoneGap/Node.js - everything is working. Except plugins loaded in a test project get this exec... error. – Zac Dec 05 '17 at 21:08
  • I think the problem is with . Try downloading and using – Jon Goodwin Dec 06 '17 at 16:25
  • Do you have the cordova.js linked in your index.html? – jcesarmobile Dec 07 '17 at 11:40
  • Yes, cordova.js is linked. – Zac Dec 07 '17 at 17:44
  • When you added the plugins, did they install without errors? Do you get any error in cli when building the app? You could try a fresh init of the app - remove node_modules, platforms, plugins and do a cordova prepare op – Andrei Mărcuţ Dec 11 '17 at 10:02

1 Answers1

2

This is the key

which I am testing on Chrome browser or PhoneGap test app.

If you test on Chrome, the Cordova plugins don't work there

If you test on the Phonegap test app, the Phonegap developer app is a Cordova app, and it has been built with some Cordova plugins, but it doesn't include the onesignal plugin, so you can't use the plugin when you test there.

So, what you have to do is to compile and run your app directly in your phone (without Chrome or Phonegap app)

I don't use Phonegap, so I'm not sure about the exact command you need. You can try

phonegap run android --device

or

phonegap cordova run android --device

or

cordova run android --device (this might require to install the Cordova CLI npm install -g cordova)

You will need to install the Android SDK to make previous commands to work.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176