Our app uses Phonegap's inappbrowser to point to our website. Our website (written in Laravel) has an edit profile page where you can upload a profile pic. This works fine on desktop but in the Phonegap app tapping the 'Choose Picture' button does not bring up the Android file system or gallery. I've installed both file system plugin and file transfer plugin for Cordova and it doesn't make a difference. Is my only choice really to re-write this part of the app custom for Phonegap using JS?
<input type="file" has a lot of know errors on mobile and isn't supported with Android WebViews in general. I would suggest using the FileTransfer Plugin to accomplish what you're trying to do. Use the upload method of this plugin to manually upload the file to the remote server. Also look at the Camera Plugin to choose which image on the device to upload.
Install the plugin cordova camera and also FileTransfer, I think that could help you much more than any kind of input, remembers working in the default browser and operating system often fail with different html attributes. There are several ways to get the picture from the device to make an upload to a server. If you're only working on Android, check your code on several devices since in some models (mostly Motorola) my fault I often a code if it works in Samsung for example. Always keep your updated plugins.
Plugin Camera
FileTransfer
Related
I successfully added the inAppBrowser Plugin to my Cordova (Ionic) app, but browsing through pages in the link I cannot download files or display PDFs, even though I can in other pages of my app (not in the iAB).
I tried to debug the plugin with adb, but i could not find anything.
Anyone has a solution for this?
I have had issues with the inAppBrowser and PDF's.
The current way I am doing it is by using a document viewer plugin: https://github.com/sitewaerts/cordova-plugin-document-viewer
It isn't ideal as it uses a 2nd app to display the PDF, but it's good enough for now. My aim is to eventually develop my own solution using PDF.js
I am making an app using ionic cordova, where image will sync automatically in my server as soon user clicks photo from their camera. I am not experienced in writing native android, hence I am looking for a cordova plugin which can be integrated in my ionic app. If there is no plugin, can someone please give me direction on how I can achieve this?
What you'll need are:
Cordova Camera plugin (this can be used to take pictures or select
from the device gallery).
Cordova File transfer plugin (used for file
uploads and download)
See a full code sample here https://gist.github.com/Whebcraft/befb0d757622d405808854745c3cd6a1
Intending to view a PDF File from the Hybrid Mobile App , created using HTML5 Jquery and Packaged with Phonegap.
But unable to achieve it ,
Things i tried
<object src="xyz.pdf" type="application/pdf"></object>
also,
window.open('xyz.pdf'); //through javascript
and
$(document).load('xyz.pdf');
Can anyone suggest the best way for viewing the PDF in a Hybrid Android Mobile App.
with cordova you must think about these:
HTML 5 object tag: not working
If you try with:
window.open('http://www.???.com/my.pdf', '_blank', 'location=yes');
The InAppViewer canĀ“t open this kind of files.
I think that there aren't an hybrid solution for this problem.
You must start to search or write about a plugin that use a native pdf's opening and then use it.
An example:
cordova-plugin-file-opener
The latest solution, a little more simple but include to open google docs is:
window.open('https://docs.google.com/viewer? url=http://www.example.com/test.pdf&embedded=true', '_blank', 'location=yes');
ref = window.open('index.html', '_self');
Go look at the Mozilla pdfJS project.
This project allows you to open a pdf (embedded in app or remote) in your app. No break-out links that relies on native viewers.
They also give you a very full featured sample viewer, that you can use as is, but much of functionality in that does not apply to mobile applications.
I have had success with this on Android 4.3 Devices.
Try installing the InAppBrowser plugin to do so. I have use it to open PDF files right inside the app on both iOS and Android.
Check the official InAppBrowser doc with full doc and examples, it has several options you can enable/disable (be sure to point to your current cordova version documentation):
My solution for connected apps with offline availability...
window.open('http://www.someserver.com/doc.pdf', '_system')
...this will open in default pdf viewer. I have my clients use adobe reader for obvious reasons. And also because once it is downloaded the first time, adobe app manages and edits the documents well, and the documents are also available offline from within adobe reader thereafter. Even pdf forms.
Have cordova.js linked on the page.
Have inAppBrowser added.
For full offline you may try FileOpener plugin. I have not needed to do that on android, but I have used that way in iOS.
Hope any of this may help.
Though am late here, still want to share what I know. You can use this plugin to view PDFs in the app (without inappbrowser). Supports only Android and iOS.
I am making a Hybrid Application using cordova-cli. My requirement is that the first page in my application must redirect to a website. The entire data required for the application will be loaded into this website from some other data-sources.
The requirement is to access device native features such as camera, accelerometer etc. from pages on this website.
I am using
location.href="http://www.example.com";
to open the pages. I need a unified cordova.js file with all the plugins embedded into it.
Currently I am putting the individual plugins into the lib\android\plugin\android and by using the grunt -f command from grunt-cli, the cordova.js file recieved for android does not seem to produce expected results.
Can't be done I am afraid - because of the way Cordova interacts with the device.
What happens if, using a non-mobile device, you accessed the same website from elsewhere? The website will not know what on earth Cordova is.
Cordova interacts with the native code on the device, so requires this to handle the passing of JS-to-native, and vice-versa.
I am a developer of DisciplineXgames! We are developing a mobile app. We have downloaded the Cordova test suite from here (https://github.com/apache/cordova-mobile-spec). When I upload this on DisciplineXgames server it shows an error in alert box "Error: Apache Cordova did not initialize. Demo will not run correctly." but when we upload the same folder on Phonegap server it works perfectly fine. Unfortunately this doesn't solve our problem as we are building our mobile app on our server and just using Phonegap to redirect the user to the page hosted on DisciplineXgames server if there's Internet in the user's mobile.
First error which I got in the console area in Google Chrome is cordova.js missing when I provided that than it outputs another error that is cordova/channel is required.
Hope you can guide us through how we can use Cordova's amazing features on our server instead of Phonegap's local server.
I am a bit confused as to what you are trying to accomplish here but I am going to take a stab.
You want to develop an app that when the app launches, it checks to see if the device has internet connectivity. If it does, then the app just opens the mobile website hosted on your servers. if there is no internet connectivity then the app ???
Since this is a very simple use case for an app, I would avoid using cordova and instead use PhoneGap Build. Simply write an index.html page and a .js file to check for the connectivity and then use the inappbrowser plugin to open your mobile site if there is connectivity. Once that is done, zip your package, upload to phonegap build and then download your compiled apps.
phoneGap Build allows you to avoid the app building overhead and the need to install things BUT prevents you from taking advantage of some of the deeper configurations and some plugins. But again, for your simple use case, PhoneGap Build sounds like the way to go.