IOS file association - default app to open certain file - iphone

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?

Related

Desktop Sandboxing Issue with Swift macOS

I've been trying to write a Mac app lately, and have run into an issue. This is not overly major but it would be great to have a solution.
I have to load an image at runtime, specified by the user (so no, I cannot embed the image into the bundle as many alternatives suggest), and embed it into an NSTextView using NSAttributedText. The image loads fine from the Pictures directory (/Users/USERNAME/Pictures/IMAGE) etc, but not from the Desktop. I have checked the Capabilities tab in Xcode, and Read/Write is enabled for all of the available options:image
Using FileManager, I have determined that the file definitely exists, but is not readable. Can I set this manually in the Entitlements file?
Thanks in advance.
No, you can't. The standard desktop is not accessible out of the box if the app is sandboxed. Only the standard Downloads, Pictures, Music and Movies folder are accessible with the corresponding entitlement.
There are two options to access the other folders but in all cases the user must choose them once
Open/Save dialog for temporary access if the appropriate entitlement is set.
A security scoped bookmark for permanent access but also in this case the user must first choose the folder once via Open/Save dialog and the security scoped bookmark must be created programmatically.

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

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.

iOS open file in another application - permissions

I have a file (an Autodesk dwf file to be precise) which I include with my app as a resource.
I would like to open the file in another program using something like [UIApplication openURL:otherapp://path/to/my/file.dwf];
The other app support the custom url scheme. When my code runs, the other app is opened, but the file isn't.
Is this because the file is in my application's resources directory and the other app isn't allowed to "play in that sandbox"? If so, where can I place the file on the phone's file system so that both applications have permission to open it?
Perhaps there's something more fundamental I'm missing.
Thanks

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.