Phonegap: initiate download on iOS - ios

Within my app I'm making a zip file (using JSZip) which I need to download (not write to the file system, but actually initiate a download) to the iOS device where the app is hosted. Is it possible to do this?

You might get the effect you're looking for with the InAppBrowser plugin. It should try to open the file with the built-in browser and then it would be up to the user to handle it.
window.open('http://location.to/the.zip', '_system');

Related

Is there a way to open an editor app in ios and receive edited results?

I have an app that downloads files from a web server. Our customer wants the ability to edit those files on their mobile devices and upload the edited version to our servers. Is this possible in iOS? I have figured out how to allow users to view the files in external apps, but I don't see a way to bring back their changes if the file was modified as it seems to copy the file into the other app's space, so my app is left with the unaltered version.
iOS has a sandbox mechanism, so for sure you can not modify any file in another app.
The only way to transfer data from different app is using sharing.
This is a sample project I wrote for implement sharing on iOS, check it:
Sample for sharing on iOS
Hope it can help you.

Downloading and Installing IPA from server if user clicks on button on Iphone

I am working on an app where I deploy the .ipa file and manifest.plist on my server and from there I try to install the app to my iphone.
The app is initially installed but I need to check if a latest version is available on the server. I have done this part and now wish to install the latest .ipa from the server directly to my phone without redirecting user to the html page of the server
Found some links on stack overflow, especially this:
Download and install an ipa from url on iOS
I have done this:
let endPointURL = NSURL(string: "itms-services://?action=download-manifest&url=myUrlString")
UIApplication.sharedApplication().openURL(endPointURL!)
I get unsupported URL exception. Can anyone tell me how I can achieve this? Is there any other way to directly start installing the upgrade without navigating to the actual html page?
It's just for testing purpose. Only registered devices are allowed to do this.
Only single way is there to download your app and its app store. You can give app store link and it will redirect user to appstore.
And if you want to test just use test flight it's easiest way.
Your linked question also tells that. Just for testing purpose it's possible now.
I found this same issue before.
A workaround for this is to new up a webview (you can hide it if you wish) and then give the request to the webview to perform. When the request loads you will then be shown the popup asking if you wish to download the app.

Opening a local file with InAppBrowser under iOS doesn't work

I am developping a mobile application using Cordova. This application allows users to navigate in a kind of a file manager and allows them to download files. I use the plugin "FileTransfer" to download the file on the user's device and then call the InAppBrowser (version 0.5.2) plugin in order to open it.
While it works really great under Android, I can't say the same under iOS (tested under versions 7 and 8).
This is the line of code I use to open the downloaded file:
window.open(entry.toURL(), "_system");
Under Android, it proposes the user which application he wants to launch to open the file or launches automatically the default application based on the file extension. Under iOS, the file is downloaded and then nothing happens. I have found out I could use the integrated viewer of the InAppBrowser plugin when the user is under iOS. I do that in this way:
if (navigator.userAgent.match(/iPhone|iPod|iPad/))
window.open(entry.toURL(), "_blank");
else
window.open(entry.toURL(), "_system");
With these lines of codes, if the user is under iOS, the integrated viewer is launched and displays the file. The problem is for ZIP files or other files that can't be rendered in the viewer. This one says "Load Error".
I think that if "_system" worked, Safari would be launched and would propose the user how he wants to open the file.
Does anybody have an idea of how I can make "_system" worked in iOS? Is this eventually a known problem (I couldn't find anything related to my problem)?
If this can be relevant to my problem, I use Phonegap Build in order to generate the .ipa file.
On iOS when you use _system, it try to open the url you pass with safari.
As iOS have sandbox access limitations, safari can't open the url because it's inside your app sandbox.
You can try this plugin, it provides an "open with" dialog that will show you the apps that support the type of file you want to open if any available.
https://build.phonegap.com/plugins/1076

Writing to a file in my iOS app

I have an app that downloads files that need to be edited and submitted back to the server through the app. These files could be anything, but are most likely to be .docs. I want to be able to open and edit these files in another app on the device, such as a .doc editor.
I've been able to get this functionality to work in similar Android and Chrome apps, but I'm very new to iOS so I'm not sure what my options are.
Is there a way to give permission for another app to edit a file that is in my app's sandbox? If not, is there a way to get the file back for submittal (like finding it through a file explorer launched through my app - similar to an 'Open..." file explorer dialog used in Windows/Mac OS/Chrome)? Am I going to have to create a way for the editor app to share the edited file back to my app?
Thanks in advance for your help!
To manage the file and the paths take a look at the documentation for NSFileManager:
https://developer.apple.com/LIBRARY/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html
I usually write using NSFileHandle for reading and writing:
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileHandle_Class/Reference/Reference.html
Hope this helps.
iOS8 will provide methods to allow apps to co-operate with "extensions".
See "Creating Extensions for iOS and OS X, Part 1 & 2` in the WWDC14 videos.
Also see the Apple "App Extension Programming Guide".
I ended up sending the file to a 3rd party app for editing and then sending the file back from the 3rd app to my app.

Automatic download file in iOS

When user downloads the app & if there is any new content on the server (e.g. .xml file) then it will automatically download to the app, Even if app is not open
Does apple allow this kind of functionality?
If yes, then how can I implement this feature?
Help me to solve this.
Thank you.
If you mean user just downloaded the app and not open and your application will start the downloading then its Big NO.
If you want to download the new contains then you have to do write code to check, validate and then download the data from server.

Resources