Return to app from safari

2019-01-22 09:42发布

问题:

In my application, I redirect the user to the safari browser when he/she taps on a button, which in turn closes the application and opens the safari browser. There is no problem in that. It works fine. The thing is when the user quits the safari browser, I want to redirect the user back to the application, not the home screen. Any idea please...

回答1:

If you control the website that you are redirecting them to, then you can place a link on the site using custom URL which I describe in more details below. But if it's a site you don't control, you can have the user surf within your app using the UIWebView.

For an iOS app, you can create custom URL schemes that your app register with the system. Then on the web page you would create a link using that custom URL. That is how Apple launches the telephone.app or the mail.app from mobile safari.

For example: Let say your app is call BigBadApp. You custom URL would be: bigbadapp:// Now, you could create a link to your app would be: <a href="bigbadapp://launchedfromsafari">Launch BigBadApp</a> You can pass any kind of information back to your app using the custom URL and your app will handle that information in the app delegate. For iOS 4.2 and later: application:openURL:sourceApplication:annotation:. The name of old delegate on earlier version of iOS is application:handleOpenURL:

For more information see check Apple Implementing Custom URL Schemes. Also iOS developer:tips has a tutorial on Launching Your Own Application via a Custom URL Scheme.



回答2:

You can't. When you redirect someone out of your application the only way to get back is using the task switcher or opening your application from the home screen again.

If you want to keep the user in your application you could open the web pages in a webview within your application



回答3:

use UIwebViewController . that represent web link within app . so that your app wont be in back ground and add back button in navigation bar on click back button navigate to back screen . i guess it would be better



回答4:

i would launch an in app browser...

this is a good uiviewcontroller subclass that has most of the browser functions already implemented. its very easy to use. https://github.com/samvermette/SVWebViewController