opening file from mail in Unity3d app and handling the file - unity3d

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

Related

How do I forward a download file to my app in 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.

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).

How do I create a app specific file type for iOS

How do I create an app specific file type for iOS and then save my app's data into this file which I can attach to emails and then other uses of the app can open this file in the app.
Mindjet for iPad does this.
See this question: How do I associate file types with an iPhone application?.
And read up on UTI: http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/understanding_utis/understand_utis_intro/understand_utis_intro.html

IOS file association - default app to open certain file

Is there any way to make my application default to open certain file types(e.g from Mail app). In this moment it is opened by Preview by default and the application is listed in the Open in.... Howeever, preview has nothing to do with this file type and this application is the only one, that can handle this file type.
So I would like to make my application default for this file type, so Preview will not open it by default. Some google search has revealed that in Mac OSX there is key like LSIsAppleDefaultForType, that can make app default, but I can't find any option for IOS...
You have to associate you app with the file types you want it to open.
You do this by adding some parameters to your Info.plist.
This post explains it:
How do I associate file types with an iPhone application?

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.