How do I forward a download file to my app in swift? - swift

I created an app for updating FW. And I want to add a function which is forward a download file to my app.
Exactly, when I download a fw file from an e-mail, I want to forward that to my app.
After I download the file, when I press the 'more' button, my app appears in the list, and I want to click on it to forward the file.
I found many methods to solve this problem, like 'add in info.plist "Application supports iTunes file sharing -> YES"', 'share extention' and so on. But they are methods which can forward a file from my app to another app. I need 'how to forward a download file to my app'.

It depends on the file type you're trying to handle. If it's one of the known types, then all you need to do is add this type to Document Files in your info.plist filie and your app will show up as a handler of this file inside UIActivityViewController.
There's already a great official tutorial on how to add file types that your app can handle: https://developer.apple.com/library/archive/qa/qa1587/_index.html
After that, all you have to do is implement application(_:open:options:) inside your AppDelegate.

Related

opening file from mail in Unity3d app and handling the file

I wish to create my own file type to use in my app. I have already linked a file type to my app but now i need to tell the app to handle the file, so when i open a file that i sent over email, i open it with my app.
This is where i didn't figure it out yet.
How can i handle the file that i sent via email in unity3d code?
If you set the property "Application supports iTunes file sharing" to true in Xcode -> Info -> Custom iOS Target Properties, you will see that the file you've opened with your app is visible in itunes -> your_device -> Apps -> File Sharing in a folder named "Inbox".
So, what unity3d does, it makes a copy of the file you've opened with your app and stores it in your Documents folder for your app under the Inbox folder. Hope this is useful.
Also, you can implement this in native code (iOS) from here: http://www.raywenderlich.com/1980/email-tutorial-for-ios-how-to-import-and-export-app-data-via-email-in-your-ios-app

Downloading "mobileconfig" file from an App

My org is creating an app, that will have certain wifi hotspots listed in a mobile config file, so that the user does not have to write the password for these wifi when he is in range.
I know this can be done using .mobileconfig file. But I have serious doubts.
Here are few questions regarding the app:
Can .mobileconfig file be created programatically. I cannot find a link to how to cretae this programatically (not using iPCU).
Will Apple allow an app that creates .mobileconfig file and asks the user to download it and install it, so as to change the wifi settings?
Is making the user download this .mobileconfig file only possible via Safari or Mail? Is there any way that this file be opened directly from the app to the settings screen?
Thanks in advance. :)
1) Yes it can. It can be created as an XML file. In fact, you can open and edit an unsigned .mobileconfig file in a text editor and edit the fields. Keep in mind that if it's signed then any edits to the file will require you to re-sign it.
2) Apple will allow an app that downloads and installs a .mobileconfig via Safari, I've seen one on the App Store that does this.
3) Safari + Mail are the only ways to open them(on iOS).

Launch app without knowing the url scheme

I want to launch another app which is programmed by other programmer in my own app. I know the method of url scheme but the problem is that I do not know the URL scheme of the app that I want to launch. Also, I googled some website to search the URL scheme yet got nothing. I think it's because the app is not used widely.
Is there any way to get the URL scheme??
Or is there another way to launch the app??
You can inspect the Info.plist file of the app by extracting the .ipa file:
Sync the App to iTunes, if necessary.
Ctrl-Click on the App in iTunes, and use "Show in Finder" to locate the "OtherApp.ipa" file.
Copy "OtherApp.ipa" to a temporary directory, and use "unzip OtherApp.ipa" on the command line to extract the archive.
Open "Info.plist" inside the "Payload/OtherApp" folder.
First of all, you have to know that not every app uses URL schemes. It's possible the app you're trying to launch doesn't use them and in that case you're out of luck.
Take a look at the Info.plist file inside the app bundle and search for the CFBundleURLSchemes key to know if URL schemes are supported.
If you don't find anything I would suggest you to contact the developer directly and telling him what you're trying to achieve.

iPhone "Share" button

Is there anything like the Android's "Share" button in iPhone?
I am just starting out in iOS development and do not have an iPhone (yet). The idea is to be able to select documents or images saved on the phone and use them in my app. I realize there is an ImagePickerController but that is not what I am looking for. I am also not looking for a third party component, rather something integrated into the OS similar to Android.
Short answer: No.
You can register your app to handle certain file types, and files of those types can then be opened by your app via UIActionSheets that may appear, for example, when you tap and hold on a file in an email. You can also transfer files to your app via iTunes. There's no 'file explorer' type feature in iOS where you can pull up a view of files saved to your phone.
For images, as you mentioned already, you must use UIImagePickerController.
From documentation
Sharing Files with the User
Applications that want to make user data files accessible can do so using application file sharing. File sharing enables the application to expose the contents of its /Documents directory to the user through iTunes. The user can then move files back and forth between the device and a desktop computer. This feature does not allow your application to share files with other applications on the same device, though. To share data and files between applications, you must the pasteboard or a document interaction controller object.
You can read more here:
https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StandardBehaviors/StandardBehaviors.html%23//apple_ref/doc/uid/TP40007072-CH4-SW7

How does "Open With" some app in iPhone work?

As far as I know, from iOS SDK 3.2, file type handling is added and an iOS application can associate itself with some file type so that other applications can open this kind of file with the application.
Because of the sandbox mechanism in iOS, I wonder when a file in appA is opened with appB, which registered itself with this kind of file, what will happen? Is this file copied to appB and both appA and appB keep a copy of this file? If the answer is yes, is it possible to make appB open the file under appA's document folder? I cannot find any Apple documentation on this.
For example, appA stores a Keynote document in it, if I open this Keynote document with the Keynote app, is it possible to let Keynote app to edit this document in place so that after editing, appA can see the updated document?
Any help is appreciated.
There are a few different questions in here.
When you register your app to handle types of files using the info.plist entry Document types your app will be on the list of apps that are shown when you perform an action with that file (for example tapping a file attachment in an email). Then when your app is launched, the method application:didFinishLaunchingWithOptions: is run as normal, and the launchOptions dictionary will contain the path to the file that was sent to your app. What you do with the file from there is up to you, but it is a copy of the file, not a link to it. So if the user makes changes to the file in the original app they must 'launch' your app again, with the new file.
See here for more info: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didFinishLaunchingWithOptions:
You can't access any other app's document folder with the current SDK.
Also, for sharing documents in iTunes (like Pages, Numbers etc), look into the two info.plist entries Document types and UIFileSharingEnabled. (Apples docs: http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW20) Basically, by setting UIFileSharingEnabled to YES you will expose the /Documents directory of your app in iTunes. Then again it's up to your to show the user once they are back in your app what's in that directory.
Sndbox implemented over standard unix permissions control. All applications are stored in folders with unique name (actually, GUIDs), however owner for them is the same mobile:mobile.
So it looks like they just sends full file path to application which opens the corresponding file.