open last used app from current app using Custom URL Schemes - ios

Am I able to open app from browser using Custom URL Schemes, now I need open a browser back this app after click cancel button in app. how can I open a browser? is it possible?
are can we open last used app from this app?

You can open safari back with below line.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"http://www.google.com"]];
However it will not open the browser with the state from where it went into background.
We can not open last used application. We can open it only if we know its custom URL.

Related

Open iOS settings from the app

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
I am using this code to open settings app from my app. But is there any URL to open Background App Refresh settings from my app?
No, you are not able to open any specific part in setting from your app. You are just able to redirect to user to those settings which are related to your app permission.

How to open any iOS App from my own App

What I want to do is open any iOS Application (Evernote, safari, Facebook, etc) from my own iOS application. For example, I have created my app with two simple buttons, the first one is named "Evernote" and the second one is named "Safari", so when I click on the "Evernote" button I want that the Evernote App launch on my iOS device, the same when I click on the "Safari" button I want that the button opens my Safari App. How can I do that? It is that possible? If it is, please tell me how. Thank you very much.
yes it possible if you known this app scheme reference URL.
Example call Tel app:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"tel://"]]){
NSString *tell = [#"tel://" stringByAppendingString:phoneNumber];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:tell]];
}
Safari and other is same way.
List common schemes Url here : http://wiki.akosma.com/IPhone_URL_Schemes
Hope this link helps you.
http://code.tutsplus.com/tutorials/ios-sdk-working-with-url-schemes--mobile-6629
If you need to open external apps from your app then follow the above link. Or if you need to open the iOS native apps like phone, mail, safari, etc, you can use URL schemes for opening the app.

Automatically open an app within iOS

I'm currently developing an app for iOS and I've got a list of PDF files in the app which I want to be able to open (and show).
Now I do know you can do that with the UIDocumentInteractionController, which then shows what apps are able to open the specific file, but I'm looking for a solution where I can open an app (e.g. Adobe Reader) without first having to open the UIDocumentInteractionController, tapping the app I want and then opening it.
Is this possible? And if so: how?
Thanks in advance!
DckWlff
You can have a look at URL Schemes. But the app you want to open needs to support it.
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
You can open an app in your App like this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"myapp://"]];
Edit:
You can find some schemes here: http://schemes.zwapp.com

iOS Simulator WebApp/Bookmark for URL Scheme testing

I'm testing a custom URL scheme in my app, and I'd like to add a homescreen icon that calls that url. Whenever I request my custom URL, it opens my app, and then reverts Safari's address bar to the previously shown URL.
I tried to skirt this issue by editing the properties of another URL, e.g.
Open Safari
Navigate to http://google.com
Tap the action button, and then "Add to home"
But this fails because you can't edit the URL assigned to the homescreen app.
As a fallback, I thought about just having a bookmark to the application, so I tried to bookmark a website and then edit the URL like this:
Open Safari
Navigate to http://google.com
Tap the action button, and then "Bookmark"
but this fails because on the iOS simulator, you can't edit the URL of a bookmark (although you can do this on the device for some reason).
update: As tkanzakic points out, you can edit user-added bookmarks, just not the predefined bookmarks
Ideally, I'd like a homescreen app, but would settle for a bookmark instead.
Also, due to firewall restrictions, I can't connect this device to my Apple account, meaning I can't sync my Safari bookmarks either.
Ah, figured it out. You can get a webapp on the homescreen pointing to any URL by following these steps:
In mobile safari, navigate to any webpage, tap the action button and make a home screen icon for this webpage.
Close the simulator
Open the directory /Users/<USERNAME>/Library/Application Support/iPhone Simulator/6.1/Library/WebClips
The webclips folder stores all the homescreen webapps; find the one you just created and open the Info.plist file in a text editor.
Edit the keys (such as URL and Title) as desired.
When you next relaunch the simulator, you homescreen webapp will point to the new URL.
Optionally, you can change the icon.png to change the webapp's icon.
As a fallback, I thought about just having a bookmark to the application, so I tried to bookmark a website and then edit the URL like this:
Open Safari
Navigate to http://google.com
Tap the action button, and then "Bookmark"
but this fails because on the iOS simulator, you can't edit the URL of a bookmark (although you can do this on the device for some reason).
That is not true, it is possible to change the URL a bookmark, check this article to see how you can do it. I have done this on the Simulator and on a Device.
Just create a small app (using Xcode) that opens the URL in its application delegate:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[application openURL:[NSURL URLWithString:#"myappscheme://whatever/"]];
}
Note that I'm using applicationDidBecomeActive: instead of applicationDidFinishLaunching: to make the launcher app work after it has been launched before.
Alternatively you could set UIApplicationExitsOnSuspend in the Info.plist to force termination.

App as shortcut for website

I want to create an app that will act as a shortcut for my website.So basically what i want to do is when user click on app icon it opens my website in safari or other browser and close the app.
I know its not recommended to close app as per apple guideline but i want to do it gracefully like it opens browser now its work is done; close the app.
Does anybody have any idea?
I can open the browser using
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"myurl"]];
but don't have any idea on how to close app gracefully.
Note: you can NOT do the following in iOS apps (2016):
You can close your app by using this code.
exit(0);

Resources