I am developing on an Android mobile system, using PhoneGap with jQuery mobile. I need my app to work without internet connection. I read the two articles from HERE and THERE, trying to import all the required files about jQuery Mobile to my Phonegap app. But it still doesn't work properly without internet.
Here are the file structure and manifest cache, I do also include the JavaScript and CSS file:
Did I miss anything? Thanks!
I prepared a jQuery Mobile offline example. Please find detailed info how to do it here.
Are you serving up your manifest file with the correct MIME type? The manifest needs to be sent with the text/cache-manifest MIME type.
Also while I can't say for sure why you application isn't working, one thing to keep in mind is that in a phonegap application the initial page is served up from the filesystem so if you have all your pages bundled together in your phonegap application you shouldn't a manifest file to make it offline.
you also need to specify network and fallback(optional) as follows :
Line starting with # are comment
# (*) online whitelist wildcard flag
NETWORK:
*
#This is optional
#FALLBACK:
#/ /offline.php
Related
My Flutter (Android and iOS) app generates KML or GPX files, which works as expected.
Now I want to add a button "Open file" which should open such a system dialog where the installed map or other consuming apps (which can handle such formats) are listed to be chosen.
How can I open this dialog? How can I find the format-related apps and how can I send the file to these apps. I guess, there is a plugin for this, but couldn't find one. It must work on Android and iOS, nice-to have is web support.
I just saw open_file but I am not quite sure, if it works as expected because it doesn't list support for KML/GPX.
Thanks in advance!
If you found a Flutter plug-in that is open source like open_file, you could just add in the MIME types yourself.
For KML format: https://en.wikipedia.org/wiki/Keyhole_Markup_Language
For GPX format: https://en.wikipedia.org/wiki/GPS_Exchange_Format
As the package is open source I was thinking of modifying the code, as the mapping appears to be straight forward:
https://github.com/crazecoder/open_file/blob/master/ios/Classes/OpenFilePlugin.m
and
https://github.com/crazecoder/open_file/blob/master/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java
You would need to fork the projects and add in the types you wanted.
Alternately you've posted issue ticket #116
where the repo owner responded with
OpenFile.open("/sdcard/example.txt", type: "text/plain", uti: "public.plain-text");
Do respond if that works, as I was uncertain if both of the different platforms' filetype (uti vs MIME type) works universally in Flutter or if you have platform specific detection code to assign the filetype correctly.
I want to know whether when I upload my phonegap application on play store then anyone can view source code after they install my application or not.
If the source code is viewable, what steps can I take to protect it?
Basically a PhoneGap application is html/css and javascript codes wrapped in a native Android WebView. So in order to protect your source code from others, you can encode it using techniques like uglify. To a normal user, this would be enough. It is similar to what Proguard does for native Android apk. However if you want total secrecy of some part of your code logic, keep it at the server end itself. Any client facing application is readable (eg- Webpages, executable files etc).
As you may know, an apk file is actually just a zip archive, so you can try to rename (or simply force your decompressing tool to open the apk file) the file to appname.apk.zip and extract it with any zip utility.
You can however encryption your source code checkout here https://ourcodeworld.com/articles/read/386/how-to-encrypt-protect-the-source-code-of-an-android-cordova-app
I created an little application in Xamarin.Forms to get the images in my file with XLabs. It work with android and IOS.
But now, i want to import file and i search the best plugin to do that.
I found this : https://developer.xamarin.com/recipes/android/data/files/browse_files/
But it dosent exist with IOS. And i don't know if it's possible (to search and get file)
And it's why i come here, to get answers.
Can you give me a plugin or a solution to get file/path of any file with OpenDialog, intent, or page custom
Thank you
Are you wanting something that can search files outside of your app's directory on iOS or only files within the app's directory?
If you want the former, iOS severely restricts this kind of thing, unlike Android. So it is not possible to do the same thing on iOS that you can do on Android.
Look at the second paragraph here and see that the app is sandboxed which means it cannot view files outside of it's own directories.
That being said other apps can make files available to be shared with other applications, see here.
You can also get access to other files from the device's iCloud account. See this for pre-iOS 8 and this for post iOS 8.
I have an offline application cordova, composed of simple html and pictures, all inserted in a sub folder (android_asset/www/app). I would like to add a second online application (android_asset/www/update/) that, check for update, download and replace the first. Is this a reasonable solution for in app synchronization?
Thanks for the time
cordova-app-loader is an easy to use plugin to update app files via 3 simple steps:
check() for a new manifest
download() files
update() your app!
It supports android and iOS
You could achieve desired functionality if you will use Cordova File Plugin.
Main trick is to load files not from android_asset/www/app, but from location on the phone storage, using cdvfile protocol (which point to the file location on the phone SDcard).
When you application starts first time, you will go to you server and save latest app version to the phone storage, and then launch you app logic code from there.
When you check for updates, you download new files to you app location and next time application will use these files.
Cordova Hot Code Push plugin also seems to address that matter. Its code seems much cleaner than cordova-app-loader and easier to use.
This is regarding HTML5 offline apps on Android devices.
We are running into an issue where bookmarking an offline capable HTML5 app (with a complete cache manifest file) fails to load on the Android browser under the following conditions:
Bookmark the app on the browser
Switch off all wireless connectivity
Close the browser completely
Attempt to launch the bookmark from the homescreen
We end up with an "Unable to connect to the internet" message. The app works perfectly fine on iOS devices when saved to homescreen and on airplane mode.
Is there a specific way the app should be saved, or is this an Android specific quirk?
I'd check and see that:
MIME type really is text/cache-manifest.
Your cache-manifest starts with CACHE MANIFEST, your urls thereafter are either relative to the manifest or absolute URLs.
You don't have any broken links in your manifest, or a forced NETWORK: tag.
So, I had faced similar issues with chrome and android on multiple instances. Apparently there is no issue with the implementation because I tried it on FF and it worked just fine, and the same was true about safari. The only thing I presume this is caused by is, the data is getting cache for the web page on the RAM when chrome is running. If you close the browser, and android ends the process a fresh instance of chrome is initialized and your existing app data is gone. I cannot confirm this, but it seems very likely that it might be the issue.
Also check your server is configured to send the mime type correctly: How to set up your server to send the correct MIME types
What's the file name of your cache manifest? I have heard that the extension could affect android's behavior. Make sure your file ends with .manifest
In addition, make sure your server is correctly serving the MIME type for manifest files, which is text/cache-manifest
In addition to Ben Max Rubinstein's and Compid's answer, if your app url is something like this: example.com/myapp you need to add a following forward slash, like this: example.com/myapp/.
When you are online the server will redirect you automatically, but if your are offline obviously that cannot happen.
What I encountered was that the .manifest files in Apache's mime.types configuration was correctly set to text/cache-manifest and then several lines below was overwritten as application/x-ms-application (for compatibility with MS' ClickOnce thing). To resolve this I've taken different file name ending, namely .cachemanifest, configured correctly its mime type, restarted Apache, renamed manifest file as cache.cachemanifest, changed my <html> manifest attribute to point to this file, and then I was finally able to cache my web app on Android (there wasn't any problem in desktop browsers which apparently don't care about the mime type of cache manifest file). Hope this helps.