Closed corse-xx closed 7 years ago
What does "cordova plugin list" command say?
im using phonegap so substituted that in instead of cordova but:
com.jsmobile.plugins.sms 0.0.2 "sms" cordova-plugin-camera 2.2.0 "Camera" cordova-plugin-compat 1.0.0 "Compat" cordova-plugin-device 1.1.2 "Device" cordova-plugin-dialogs 1.2.1 "Notification" cordova-plugin-file 4.2.0 "File" cordova-plugin-geolocation 2.2.0 "Geolocation" cordova-plugin-media 2.3.0 "Media" cordova-plugin-network-information 1.2.1 "Network Information" cordova-plugin-statusbar 2.1.3 "StatusBar" cordova-plugin-whitelist 1.2.2 "Whitelist" phonegap-plugin-barcodescanner 5.0.1 "BarcodeScanner" pushwoosh-cordova-plugin 5.1.2 "Pushwoosh"
Could this be a reason? http://stackoverflow.com/questions/32335750/cordova-js-causes-reference-error-require-is-not-defined
The answer here is that the Cordova CLI automatically includes cordova.js and any necessary dependancies when you build the application.
The cordova.js file is placed in the www directory, so all you have to do is include that file -
<script type="text/javascript" src="cordova.js"></script>
hiya, no i don't think its that. as a simple test i do this:
if(typeof(cordova) === 'undefined') {
errLine=90000;
};
then i output errLine as part of the error message and still get errLine 402 (the line of code where i declare the variable for pushNotification.
Another guess, any chance you call this before onDeviceReady has been fired?
also can you print to the console what is the type of cordova.require?
i call it at the end of the onDeviceReady (as i say this was working perfectly with the old versions of pushwoosh). I tried putting in an extra delay just to be sure but to be honest that stopped it being called at all!
cordova.require is coming out as a function when console.log'd
I also console logged just cordova and get this (if that helps!):
{ version: '5.0.0', platformVersion: '5.0.0', platformId: 'android', callbackId: 1522664459, callbacks: { CoreAndroid1522664451: { fail: null }, Media1522664455: {}, NetworkStatus1522664456: {} }, callbackStatus: { NO_RESULT: 0, OK: 1, CLASS_NOT_FOUND_EXCEPTION: 2, ILLEGAL_ACCESS_EXCEPTION: 3, INSTANTIATION_EXCEPTION: 4, MALFORMED_URL_EXCEPTION: 5, IO_EXCEPTION: 6, INVALID_ACTION: 7, JSON_EXCEPTION: 8, ERROR: 9 }, file: { applicationDirectory: 'file:///android_asset/', applicationStorageDirectory: 'file:///data/user/0/com.adobe.phonegap.app/', dataDirectory: 'file:///data/user/0/com.adobe.phonegap.app/files/', cacheDirectory: 'file:///data/user/0/com.adobe.phonegap.app/cache/', externalApplicationStorageDirectory: 'file:///storage/emulated/0/Android/data/com.adobe.phonegap.app/', externalDataDirectory: 'file:///storage/emulated/0/Android/data/com.adobe.phonegap.app/files/', externalCacheDirectory: 'file:///storage/emulated/0/Android/data/com.adobe.phonegap.app/cache/', externalRootDirectory: 'file:///storage/emulated/0/', tempDirectory: null, syncedDataDirectory: null, documentsDirectory: null, sharedDirectory: null }, InAppBrowser: {} }
Trouble with this is i know its got to be something so simple :(
OK, can you list a cordova plugins at runtime as described here? https://www.raymondcamden.com/2014/11/19/Determing-installed-plugins-at-runtime-for-Cordova-and-PhoneGap-applications/
var md = cordova.require("cordova/plugin_list").metadata;
and log it to the console?
i think this is going to be the problem...that returns as {}
i have attached the cordova_plugins.js file as well from the platform_www folder (as android build doesnt create a www directory)
cordova_plugins.zip
Does the problem persist after cleaning the project (remove platform and plugins directories and add all plugins again)?
im afraid it does :( that was one of my first steps, cleaned it all down completely. I have even tried importing my files into a new project just in case it was that. This one has me massively stumped!
hi guys, any further ideas?
Do you have the same problem with Pushwoosh Sample? If not can you share your project?
can i install pushwoosh sample in the same way with a phonegap plugin add?
I can't share the project i am afraid, the company would kill me!
For phonegap you should use phonegap plugin add
here https://github.com/Pushwoosh/pushwoosh-phonegap-cordova-sample/blob/master/Cordova/hooks/after_platform_add/install_plugins.js#L18
i have run that sample project (i put a try catch around the initPushwoosh(); call and i get back module pushwoosh-cordova-plugin.PushNotification not found
I've checked the sample project with the same phonegap version and it works fine:
git clone https://github.com/Pushwoosh/pushwoosh-phonegap-cordova-sample.git
cd pushwoosh-phonegap-cordova-sample/Cordova
phonegap plugin add cordova-plugin-device
phonegap plugin add cordova-plugin-whitelist
phonegap plugin add pushwoosh-cordova-plugin
phonegap platform add --save android
phonegap run android
Maybe there is something wrong with your phonegap installation. You can also try Cordova CLI instead.
i have run this on a brand new build machine now, with everything installed fresh. the same thing happens through phonegap serve everytime. i am going to try an apk build and push that to a test environment to see if that corrects anything. Going to have to move away from pushwoosh if we can't get this working :(
Why don't you try Cordova CLI?
i will give that a go if this build fails as well, this was supposed to be a days worth of changes, its running a week now :(
By the way have you tried contacting phonegap guys in their support forum? They are slow but usually help. I'm terribly sorry for inconvenience. Maybe you can just leave push subscription in your project and strip all the rest of the code and share the project with me?
i do not believe this but i do need to contact phonegap now :( its phonegap serve that is broken and not allowing pushwoosh to run. The other day it wouldn't run after a publish as well so one of the steps you have given me above certainly seem to have corrected something! Thank you for the help!
Do you use Phonegap Build? right? Phonegap Build is broken (they are so slow updating Android libraries that Google recently broke) and we have released a separate plugin "pushwoosh-pgb-plugin" to workaround that. You can try that instead of "pushwoosh-cordova-plugin"?
hiya no im not using Phonegap Build. we were going to (hence using Phonegap over Cordova) but...ya know how bosses can be :) Its the phonegap serve command you can use from the cmd line to push the app to the phonegap app on android/ios that appears to be broken :(
I've had the same issue today and it was solved by changing
var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification");
to
var pushNotification = cordova.require("pushwoosh-cordova-plugin.PushNotification");
Thanks to this comment: https://github.com/phonegap/phonegap-app-developer/issues/371#issuecomment-210529878.
Hope this helps!
Hi everyone,
I have the same problem as reported by @corse-xx , although mine seems to occur only when I swipe a push notification to open my app with it to get to the notification's payload. I happens if the app is paused or not running at all, on ios and on android. I'm using the 5.0.3.1 version of the pushwoosh plugin along with the telerik appbuilder Visual Studio extension. I get a reference to the pushwoosh plugin by using this code :
document.addEventListener("deviceready", function () {
if (self.pushNotification === null) {
self.pushNotification = window.plugins.pushNotification;
}
...
The code above is in a factory type class used for angularjs (Ionic Framework) I've tried the suggestion above by @barryatswisnl above, but that did not make a difference. Any other ideas will be greatly appreciated.
As an aside, I tested with the 3.6.16.1 version that comes with the Telerik appbuilder visual studio extension and this one works fine. Could it be that the 5.0.3.1 version that Telerik provides has some bug in it ? I ask because I know they change the plugin.xml to fit within their build process, I just not sure how the plugin.xml links to the failing cordova.require function calls when a notification is swiped/used.
Why is this closed if the issue is not resolved?
the issue ended up being phonegap serve being screwy and not the plugin, so my issue which i raised is not an issue.
hi, any luck of this isseu, as i'm experiencing the same? i build using cordova and framework7, put the following code
if(typeof(cordova) === 'undefined') { app.dialog.alert('Undefined');
};var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification"); app.dialog.alert(JSON.stringify(pushwoosh));
but it always return {} why does cordova seems not working?
Hiya i have read through all the support calls to see if i can find this. My app was running just fine but with new requirements came new code and the plugin was updated to 5.1.2
I'm using phonegap version 6.2.7
The plugin is installed correctly in the plugins folder via the phonegap plugin add pushwoosh-cordova-plugin command
As soon as initPushwoosh is called and the declaration line for var pushNotification= is called i get an undefined error.
I have tried everything, please could you assist?