I am currently developing a mobile project using Cordova and Ionic2 using an external database resource that connects to the mobile via REST webServices.
The database has documents pdf saved that you have to send to the mobile and view the same. I am using the pdf in enconding Base64 through the webservices by Json.
I can get the string in base64, but I do not quite understand how to decode it and save it on mobile, which is Android to be able to see it.
Use the native File component from Ionic 2.
ionic cordova plugin add cordova-plugin-file
npm install --save #ionic-native/file
To save the base64 string on the device you call the createFile(path, fileName, replace) method.
More info: Ionic 2 File
I had a similar battle with PDF's, but dealing with them in binary/Blob form. Similar problem/solution overall. It seems that PDF opening isn't as simple as it should be across Web/Android/iOS.
Open createObjectURL Blob on Cordova InAppBrowser
Related
im using rn fetch for download file from base64 everything work great in ios but when i run it in android it show this error :
Well I am trying to download file via download manager my url adress is a base64 pdf
appreciate any help
I have a Website(ReactJs) with a pdf download functionality(via base64) and it works fine. For Android, I have a cordova app where the app is pointed to website and no actual app code resides inside cordova and this is where the problem starts.
The PDF download is not working in app and I have been restricted from using native java code or Cordova(js + file-plugin).
Is there any way to achieve this with given constraints?
What would be the simplest way to render a PDF document whose Base64 encoding is returned from a web service on an Android app built using cordova?
Can this be done without additional plugins?
Any sample code would be useful.
Currently I am working on an Ionic Cordova app which let an user upload vdo and image from android device. I finished working image upload with help of cordova camera plugin which can choose photo from user phone and return base64 data. Now i am trying to get video as i did for image. But the video return data is file url which is sth like this content://com.android.providers.media.documents/document/video%3A27227 . I don't know how to continue .
Appreciate your help
You can use that url and pass it to a fileHandler routine and read the contents of the video.
I will forewarn you that it gets very complicated with iOS and Android using different file url formats. And there's no consistency between various Android devices that I ended up using a 3rd party plugin from the Ionic market place which is worth every penny and saved me months of development time and aggravation.
I have a working web application. How would I refer to the index.html to this app's index.html?
super.loadUrl(“file:///android_asset/www/index.html”);
My web app already have the index.html. Do I just refer to that URL? Say my app is at:
www.myapp.com
Do I just type that address?
To quickly get it up and running put your index.html and any other html/images/css/javascript into zip file and upload to the PhoneGap build site. There's more to it that that but for a simple static app that will work.