Launch app without knowing the url scheme - iphone

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.

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.

iOS OTA install not registering custom URL scheme

For one of our clients, we have developed an OTA app store for distribution.
To enable testing if the apps are installed, in each of the apps I wrote, I added two custom URL schemes: one that's just the app id, and one with the app id and the version (both with . replaced by -); so for example com-mycompany-app and com-mycompany-app-1-2-0 for com.mycompany.app, version 1.2.0.
Then, in our "app store" I just use [[UIApplication sharedApplication] canOpenUrl:] to determine if an App is installed or the latest version, and if so, replace the "Install" button with an "Open" button.
When installing the app through XCode, it works great. However, when I install the same app OTA, through my "app store", the canOpenUrl: call always returns NO. To see if it was a caching thing, I have tried restarting the "app store" app after OTA install has finished, but I get the same results.
Is this an issue with my manifest plist file? In the Info.plist that belongs to the target, the custom URL Scheme stuff is obviously there, but it's not in the manifest's. However, I would imagine it only uses the manifest to launch initial install...shouldn't the Info.plist be used during actual install to register these sorts of things? Is there something else I'm missing?
Thanks!
Edit: I'm using a custom build script to actually create the .ipa and .plist files that are being used for OTA distribution. I tried using iPhone Configuration Utility to install the IPA directly, and my app store was able to recognize those URLs as being openable. The only possible things I can think of are either that the plist I'm using to download & install needs to have some sort of reference to these custom URL schemes, or it's actually a legitimate bug in Apple's OTA framework.
I got this working, in case anyone is watching this or stumbles upon a similar issue.
The only thing I changed -- and there's no documentation saying the old way wouldn't or shouldn't work -- was to use periods in my URL scheme, instead of hyphens. So com-company-app:// became com.company.app:// (same as the bundle ID), and likewise with the version-appended one.
I don't know if my old URL schemes were violating official URL spec, or if you're supposed to use reverse-DNS, but everything is working, now.

Downloading files for UIWebView to specific folder on IPhone

I have made an app that displays my website from a UIWebView and it takes you to a store that you can download files. My question is that I need to download a '.zip'file from my website using the app to the IPhone. Heres is my problem. I don't want the file to goto the App's Document folder, I want it to goto a folder that is outside of my applications folder. Here is an example path I might want my file to goto EX:'var/mobile/Library/Downloads'. If there is not a way to download the files to a path outside of the app's folder, is there a way to transfer the specific file that I have downloaded from my website using the my app to another folder that is not located in my app's folders? I know this can be done because I have used apps that have done this, of course they were apps only available on Cydia. This is also an app that will be used for Jail-broken users just for your information!
Thanks for any help!
Any "regular" iphone app runs in a sandbox that prevents access to system wide directories. Practically, you only have access to the app Home Directory.
Unless you go for a jailbroken app, you have no other options than storing to the App docs folder.
Read "The Application Sandbox" and "The File System" [here] for more details1.
EDIT:
I am not an expert on cydia, but the general idea is gaining access as root and then write to where you need to. This can be done by replacing your app with a suid shell script that will in turn exec your app (which will have root privileges now and then be able to go out of the sandbox).
For more info look at this.

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.

Access user home folder outside sandbox

I'm working on a app which will not be submitted to the AppStore and am trying to open a file which the user has downloaded using Safari Download Manager.
This plugin mentions all files are downloaded inside ~/Media/Downloads.
I've tried just using NSString's stringByExpandingTildeInPath, but it will map to /Media/Downloads inside the application sandbox.
Question is: how can I tilde-expand that path so it maps to the actual folder?
Thanks!
I assume that by "Safari Download Manager" you mean that you already have a jailbroken phone. If so, the easiest way is to just install something like iFile and find out what the path is.
I'm assuming that it's something like /var/mobile/Media/Downloads. Then, there are two easy things you can do:
Hard-code "/var/mobile" to expand a tilde at the beginning of the string.
Find out the username you want the homedir for (probably "mobile") and try expanding ~mobile/Media/Downloads.
Find the username, and get the homedir with a call to getpwnam() or so (assuming it exists on iOS).
The sandbox isn't just a necessity for App Store submission, it's a feature of the device. Without jailbreaking, you're out of luck.