Barcodescanner phonegap, cordova.plugins is undefined - visual-studio

Sounds familiar to what I found online, but I didn't get an answer to my case.
This is an Vue.js app, embedded in a cordova app, for Android.
I use Visual Studio Tools for Apache Cordova, and I installed plugins such as Camera, or phonegap's barcode scanner (installed in my project from their github).
I got Camera plugin to work, with navigator.camera.getPicture(callback).
It seems I should use phonegap's barcode scanner through cordova variable, with cordova.plugins, that's what is stated in their documentation, but this cordova.plugins is undefined.
People say plugins have to be accessed after the event deviceready fires, but even checking that, the event is indeed emitted, and just putting console.log(cordova.plugins) in the callback function, I get "undefined".
This is what I do
document.addEventListener("deviceready", () => {
console.log("The event is right !");
console.log(cordova);
console.log(cordova.plugins);
})
Everything is right except for the plugins (3rd log). cordova.plugins should be defined because I have some plugins that do use it, but it seems I'm doing something wrong... Maybe something about config.xml or package.json ?

They changed something in new versions of this plagin, so it works only in new versions of Cordova as far as I undestand. So, my solution is to use old version of the plugin temporary. For instance, in this version of the plugin cordova.plugins.barcodeScanner.scan is available from a code on my side:
https://github.com/phonegap/phonegap-plugin-barcodescanner.git#6.0.5
(you can see a version information at the end of this line)
Please let me know if you found better solution.

Related

Migrating to NativeScript 7

I'm migrating a typescript/angular based NativeScript project over to the latest version of NativeScript, and am running into an issue. Before, I was using the tns-platform-declarations plugin (https://preview.npmjs.com/package/tns-platform-declarations) so I could get intellisense (I'm using VS Code) for things like UITextView and other native calls. But when updating my project, this module is removed from package.json. And if I add it back in, it says my project is not compatible with 7.x.
Do I just need to wait until the plugin is updated, or is there another way to get intellisense going, but still use NS 7.x?
Extending on Matthew's answer. Make sure you are including in your tsconfig the references.d.ts file, the one that points to either tns-platform-declarations or #nativescript/types, depending on your NativeScript version.
When you migrate the project it will change your tns-platform-declaration to #nativescript/types
https://nativescript.org/blog/nativescript-7-announcement/

What is a Parse Collection?

I'm learning Parse (the Javascript flavor) using their Todo App tutorial. I'm trying to write my first query. In the tutorial, I found this code:
var TodoList = Parse.Collection.extend({ ... });
I can't find any info about Parse.Collection in their JS Guide nor their API docs.
Can someone shed some light on what a Parse.Collection is and when I should use it?
You're not seeing anything in the docs because Parse.Collection was removed from the JavaScript SDK in v.1.6.0.
Downloads Page and JavaScript Changelog
SDK no longer contains Backbone-specific behavior. Moving forward, the core SDK will not be tied to any single framework, but we will work with the community to produce up-to-date bindings like Parse+React. The major changes are the removal of Parse.Collection, and allowing Parse.Objects to act as event channels.
In previous versions of the SDK, Parse.Collection was used almost identically to Backbone.Collection, as the Parse SDK was based on Backbone. Things are particularly confusing right now because tutorials on parse.com use pre-1.6.0 versions of the SDK.

NoClassDefFoundError: android.support.v4.app when sending push?

Im using PushBots to manage my push notifications for my app, I have been using this amazing platform for lots of apps and its the first time I have a problem like this.
Sometimes, when I launch the app, I get this error, but always when receiving a push (within or whitout the app opened).
07-12 01:20:00.844: E/AndroidRuntime(12140): FATAL EXCEPTION: IntentService[GCMIntentService-326*****5*9-1]
07-12 01:20:00.844: E/AndroidRuntime(12140): Process: com.karlol.mo***, PID: 12140
07-12 01:20:00.844: E/AndroidRuntime(12140): java.lang.NoClassDefFoundError: android.support.v4.app.NotificationManagerCompat
> //This is just the beginning of the log, there's more with some
> Pushbots handler info and stuff.... Let me know if I need to post it,
> its a lot.
Im pretty sure this is about the android support v4, this is my current build path:
*Sometimes when I uncheck the Private Libraries clean and re-check this option again the app works (but not lucky with notifications).
The support v4 jar is in the libs folder, the route is the correct (MyApp/libs)
Im about to release an update, my app is already working/running with pushbots servers (with registered devices and all) so I would like to solve this to release my update. Thanks.
As explained in these questions: NotificationManagerCompat Can't be resolved - Android Wear and Android studio unable to import WearableExtender NotificationManagerCompat and RemoteInput. It seems that you are not using the last version of the compatibility support library. You have two options to solve that:
Download the newest libraries manually, and add them to your project.
It seems that you are using eclipse, I recommend that you now use Android Studio so you can add the dependency and let gladle handle the libraries, like this
dependencies {
compile 'com.android.support:support-v4:20.0+'
}
check mark the following jars in build path or property ,it will work
1. android-support-v4.jar(appcombat/ibs)
2.android-support-v4-appcombat.jar(appcombat/ibs)

Using jQuery Mobile in Tool for Cordova project targeted Windows Phone 8.1 & Windows 8.1 will resulted in layout not rendering properly

I am not sure if this is a known bug or some conflict with jQuery Mobile within the Tool for Cordova project but when I use jQuery Mobile inside mine project the layout did not rendered correctly.
For example, start with a blank project. I then added both jQuery 2.1.3 and jQuery Mobile 1.4.5 from NuGet. Then inside the index.html, I have added a text input element. It is pretty simple and nothing is complicated. Then trying to run the project on both simulators and real devices would yield the result that the text input element did not appear at all, even though it resided inside the DOM. Further investigation provided the same result like this question: Tools for Apache Cordova: JQueryMobile wraps input tags inside a head tag?. This did not happened when I targeted the app with Android or iOS. Everything would rendered correctly in those two platforms.
I suspect that there are some conflicts when Visual Studio built the application and injected WinJS as well as jQuery Mobile. I have searched a lot of place and there are no mentions of incompatibility between them.
After trying everything, I gone back to the basic. I started installing Cordova CLI and tested to see if this problem would be there. To my surprise, the Windows 8.1 and WP 8.1 projects from the Cordova CLI build are working perfectly fine. Everything is rendered correctly, although there was an issue with jQuery Mobile changePage().
If this is actually a bug in pre-released software, then I hope in the final release, everything should work correctly. In the meantime, anyone would like to try suggesting me a workaround for this problem. I know there are at least me and the other guy from the question that I have linked above that had issue like this.
Thanks.
Update my finding: The problem is with the library winstore-jscompat.js. Apparently, even with the new CTP 3.1, the file is not the recent one from GitHub. I downloaded the new version from GitHub, replaced it with the old one, and everything works perfectly now.
The GitHub is from here: https://github.com/MSOpenTech/winstore-jscompat.

Upgrading custom iOS plugins from Cordoba 1.7 to 2.1, how can I find out why they are never loaded?

I've got my plugins converted, or so I think, and registered in Cordova.plist. The method signatures are correct, according to this guide. Nothing has changed on the js side, yet they don't load and just fail silently. Cordova itself is working, onDeviceReady is firing, but my plugins just never get executed. Everything worked fine with 1.7...
I'd like some help to get started on figuring out where they are supposed to be loaded and/or called from js on the obj-c side. Where can I set a breakpoint in the Cordova source to see why it's not executing my plugin?
Where should I begin to look?
I just did exactly this migration. All I can say is that it worked for me if you follow the steps. You also need to follow the steps from the 1.9>2.0 migration.
Since Cordova 2.0, the framework had big changes.
Maybe is better you implements again using the 2.0 rules and, after, only override selector signature. Thus you learn how do plugin in new versions, updating your Cordova skills. :)
Single big change between 2.0 and 2.1 (for plugins)
Support a new plugin method signature (old signature is deprecated):
The new signature is:
- (void) myMethod:(CDVInvokedUrlCommand*)command;
The old (deprecated) signature is:
- (void) myMethod:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

Resources