PhoneGape Plugin comes - Forum

Forum Navigation
You need to log in to create posts and topics.

PhoneGape Plugin comes

New Session of VisualNEO Web start!

VisualNEO Web now able to create an app that use native functionality. I have test different functionality of device for instance: Accessing Camera, writing file, detecting location, push notification and much more...there are done successfully. I have made a sample plugin of BarCodeScanner that use scanner of mobile. you can see in this video how it work.

Note: add this snippet to confing.xml

<plugin name="cordova-plugin-barcodescanner" source="npm" spec="~0.7.4"/>
Uploaded files:
  • You need to login to have access to uploads.
luishp, Vadim and paeon have reacted to this post.
luishpVadimpaeon

Thank you @asmat!
Just in time with the new version XML editor :)

To everyone willing to use this plugin please note it's only for compiling into Mobile (PhoneGap)

 

Vadim and asmat have reacted to this post.
Vadimasmat

Hi @asmat,

I tried your barcode function in my sample project, compiled to PhoneGap, and it works fine. LocalStorage, while OK, is not good for long-term records...  I'm exploring Cordova/PhoneGap's FILE api.

Any  advice to get the read and write to file function working is appreciated. I added

<plugin name="cordova-plugin-file" source="npm" spec="~6.0.2" />

and try the sample read/write but nothing happens. Only your barcode function is working.

 

Hi Ronnie you are not need to add this

<plugin name="cordova-plugin-file" source="npm" spec="~6.0.2" />

This plugin already added by default.

I made a sample for reading and writing file to the file system of mobile  take a look at the attachment.

 

Uploaded files:
  • You need to login to have access to uploads.

Hi @asmat, thanks for the great help. Will explore the demo...

Hi @asmat, it works after I removed below script from my sample project. Yes, no need for that script...

<plugin name="cordova-plugin-file" source="npm" spec="~6.0.2" />

Will explore further on the file api since you've provided a great head-start on the possibilities. Thanks again!

Hi @asmat, here's my feedback after testing for a while...

The cordova file plugin  also relies on LocalStorage which, technically means, there  is no difference from using GetItem/SetItem functions in VNW directly.

I checked and found:

cordova-plugin-nativestorage  (https://www.npmjs.com/package/cordova-plugin-nativestorage)

Maybe, this could be the one allowing  reading/writing to permanent file...

 

Hi @asmat,

I'm still learning JS... I tried using the cordova nativestorage plugin but just couldn't get it to work. I've attached a modified version of your working sample fileWriteRead to include the extra buttons

I added "plugin name="cordova-plugin-nativestorage...."  in the Platform>Mobile section as I noticed this plug-in was not installed by default. After adding them, I checked and noticed it's included in the phonegap build package.

I might have missed something somewhere to read/write the file where I took the scripts from the web. Any  advice is appreciated

Regards, Ronnie

Uploaded files:
  • You need to login to have access to uploads.

Hi Ronnie lets try this

set this code for write:

BEGINJS
var obj =document.getElementById('area1').value;
NativeStorage.setItem("reference", obj,()=> alert('Success'),()=> alert('error'));
ENDJS

and this code for read:

BEGINJS
NativeStorage.getItem("reference", (obj)=>document.getElementById('area2').value=obj
, ()=>alert('error'));
ENDJS

 

Uploaded files:
  • You need to login to have access to uploads.

Hi @asmat, as always, thanks for the guidance. Appreciate the time and effort you've provided.

May I know where the data is stored? Is it in LocalStorage or in a file folder (ideal)? Reason I asked is that after successfully saving the file, i uninstall the program, and then reinstall. Then I tap on READ but there was an error.

Hi @Ronnie

The Data store in the apps root folder(it is hide if you did not root your phone). I have test in android studio the file created in this path: android/data/Application id/cache/example.txt you can see better in the attach file.

when you uninstall app, the apps root folder will remove.

Uploaded files:
  • You need to login to have access to uploads.

Hi @asmat, that’s great. I could see both files and cache folders created using EFS Explorer. But didn’t get to see the actual file, and as you said, it’s hidden unless the phone is rooted.

I noticed that if I reinstall the apk without uninstall, I could install successfully on my Sony Xperia XZ. However, if I rebuild the apk again from PhoneGap, I cannot install as it reported error. I could only install after I uninstall the existing one. That would remove the saved file too, which is sad.

Some years back, I was developing an Android app using some development tools, and regardless of whether there is a new build of my app, users can install them without affecting the user records (SQLite) saved in <app id>/files/ folder.

I hope to reproduce this with VisualNeoWeb. Is there any specific commands or scripts that can be added into CONFIG.XML to enable, read/write storage, and to overwrite previous builds?

Hi, @Ronnie, I have found a solution to your problem. add this line code in config.xml:

<preference name="AndroidPersistentFileLocation" value="Compatibility" />

whenever you uninstall and reinstall the application the saved data will not be removed.

 

luishp and CDY@44 have reacted to this post.
luishpCDY@44
Quote from asmat on March 25, 2020, 3:13 pm

I made a sample for reading and writing file to the file system of mobile  take a look at the attachment.

 

Do you have sample Android APK for this ?

I'm very interesting to try on my mobile device.

asmat has reacted to this post.
asmat

Hi See_Half, making android APK is not hard with Cordova it takes around 5 minutes.

Be careful when you compile your app with Cordova you must change phonegap.js to cordova.js from index.html:

<script src="phonegap.js"></script> //Change to this:
<script src="cordova.js"></script>

if you do not do this, you will not use any Cordova plugin.

See the attachment, I have made APK.
The attached zip file is the .apk file,  you just change the extension to .apk and then install it on your phone.

 

Uploaded files:
  • You need to login to have access to uploads.

Be careful when you compile your app with Cordova you must change phonegap.js to cordova.js from index.html:

@asmat @see_half this is not necessary anymore when working with last VisualNEO Web version

asmat has reacted to this post.
asmat

Thank you @luishp

luishp has reacted to this post.
luishp