73
Views
17
Comments
Solved
Cordova is not defined Error while using FilePlugin
Question

This is my function I have created to download entity data into excel on user's mobile device. I used the debugging tool and they returned an error that Cordova is not define. May I kindly request some guidance from the community? Thanks!

Rank: #120
Solution

Hi R Y,

I'm using the Temp directory in my project:

"tmp/"


But I only do this because I use the File Viewer Plugin to open the file. Then the user will be asked to choose the destination that he pretends. Since the Temp directory is automatically cleared by the Operating System, this works perfectly for me.


In your case, according to your needs, maybe you could try the Documents directory or the Data directory:

"Documents/"
"NoCloud/"


Let me know if it worked for you.


Kind regards,

Rui Barradas

Rank: #120

Hi,

Are you trying to test this functionality in the browser or using a mobile device?


Kind regards,

Rui Barradas

Rank: #120

Hi again,

Then that's your problem :)

Plugins enable capabilities of the mobile device. So they can't be tested in the browser, that's why you're getting that error (cordova is not defined).

Most likely, you need to generate the builds for your application (APK file for Android and IPA file for iOS) and test that functionality in a mobile device.


Kind regards,

Rui Barradas

Rank: #120

Hi again R Y,

To be honest, I don't think so. In my mobile applications, I'm using File Plugin myself when it becomes to download files to the device.


Kind regards,

Rui Barradas

Rank: #120

Hi again R Y,

Yes, that is correct.

Every single function or functionality that you use from a plugin, it requires to be tested on a mobile device. Everytime you add a new plugin to your application, it requires for you to generate new builds (APK or IPA files) and install the new version on your mobile device. This will allow you to test the new capabilities associated to that new plugin.


Kind regards,

Rui Barradas

Rank: #120

Hi again R Y,

I would like to share with you some documentation that could be useful for you in order to generate and distribute your mobile app. This could also be important if you want to test it on your mobile device during your development phase.

https://success.outsystems.com/Documentation/10/Delivering_Mobile_Apps/Generate_and_Distribute_Your_Mobile_App 

https://success.outsystems.com/Documentation/10/Delivering_Mobile_Apps/Generate_and_Distribute_Your_Mobile_App/Generate_and_Distribute_Your_Mobile_App_for_Development_Tests 


Hope that it helps.

Let me know if you have any further questions.


Kind regards,

Rui Barradas

Rank: #120

Hi again R Y,

Hope you're doing well.

For testing purposes on a iOS device, you need to generate the IPA file. Unfortunately, you can't do that without a developer's account (because you need to create a Provisioning Profile).

My suggestion (if possible) is that you test on an Android device. Because it is way easier to generate and install the APK file, compared to iOS devices.


Another alternative is the OutSystems Now app that you can download from the stores. It should allow you to test some functionalities of your application on your mobile device, using a QR code associated to your app (that you can see in Service Studio or when you open your app in a browser). I never tested the File Plugin using OutSystems Now, but you could give it a try.


About your File Plugin question, are you using an Android or iOS device? They have different System Layouts, but the plugin allows you specify which is the directory where you want to save the file.

Please check this link:

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/ 

You just need to specify the device path and the file should be saved there.


Kind regards,

Rui Barradas

Rank: #120

Hi R Y,

Yes, you are correct. The file system layout for iOS is quite difficult to access compared to Android. There are some directories that are not accessible by default.

My suggestion is that you specify the file path instead of letting it be downloaded to a default location, otherwise the file will be saved in the local app folder.

If it was an Android device, you could still access to that folder and access the file, but that is not possible for iOS (at least not without using any additional tools).


Kind regards,

Rui Barradas

Rank: #120
Solution

Hi R Y,

I'm using the Temp directory in my project:

"tmp/"


But I only do this because I use the File Viewer Plugin to open the file. Then the user will be asked to choose the destination that he pretends. Since the Temp directory is automatically cleared by the Operating System, this works perfectly for me.


In your case, according to your needs, maybe you could try the Documents directory or the Data directory:

"Documents/"
"NoCloud/"


Let me know if it worked for you.


Kind regards,

Rui Barradas

Rank: #120

Hello again R Y,

No need to thank me, I'm always glad to help.

Are you talking about the action that I use to save the file using File Plugin? Or a sample about the File Viewer Plugin?


Kind regards,

Rui Barradas