iOS returning from safari (or another app) - ios

My problem is the following: in my app, I need to switch to safari for a login; however, when the user is redirected to my app, I want a specific action to be executed. Is there a way to do that? ViewWillAppear doesn't work, since it's called only the first time the views shows up....
Thanks for the help :)

You could register your iOS app to handle URL scheme 'foo', then invoke or have a link pointing to 'foo://my_custom_launch_action' from your website. When your app launches, you may read the launch options and act accordingly.
I think the official Flickr app for iPhone implements this mechanism to authenticate users through Safari from outside the app.

Related

How to do deep linking from app/browser to native iOS app with 2 different urls

I am working on project where I have been implementing deep linking from app/browser to my app. I have everything setup and it has been working as expected.
But recently, there is changed to the other app where there is new url introduced, which is launching in the browser and that url has changed to exiting url. But it is not launching my app. How to implement and launch my app with that change?
Example
--> deep link url, https://www.externalApp.com/requestPage=homePage&id=4444
--> When user tap on button on the external app, the above URL is invoke and launch the my app.
After change
--> Now new url, http://www.externalApp.com/request=sometoken
--> when user tap on button, http://www.externalApp.com/request=sometoken invoke and open browser and then become https://www.externalApp.com/requestPage=homePage&id=4444 in the browser. But it is staying in the browser and not opening my app.
Expectation is to launch app after url become https://www.externalApp.com/requestPage=homePage&id=4444.
Please help and advise.
A URL redirect will not trigger your app deeplink under any circumstance.
The ideal way to do this would be for your app to handle the URL http://www.externalApp.com/request=sometoken and convert it into https://www.externalApp.com/requestPage=homePage&id=4444 using whatever logic you are currently executing server-side (or on the webpage).
If this is not possible in any way, then the discussion goes into the direction of ugly hacks where you try to trigger the deeplink using Javscript, which can fail (since you cannot guarantee that the deeplinked app is present on the device). I would not delve into those pathways here and recommend you re-think your solution.
Please note that I do not mean to disparage or deride your implementation in any way. You may have a valid use-case where such a flow is required. But with how universal links work on iOS, the above is my recommendation based on my experience as a developer.

Directly return back to app from Safari without prompting the user

I have gone through similar questions and the answer to all of them is using custom URL, which I did implement. However in case of custom URL's, when the user is being redirected back to the app from Safari, there is a popup that says Do you want to open (app name). I don't want to show this popup to the user , instead I want to navigate them directly to the app. How can I achieve this ? Any help is greatly appreciated.
You cannot do this with URI schemes — they will always show this alert in Safari.
If you want to route into your app without showing an alert, you need to use Universal Links.

Is there a way to get back to your application from the settings page of iphone

I have designed an app where the app needs to enable the GPS. There is a page for the user which ask use GPS? To this answer there are 2 options YES and NO. Now my concern is when user clicks on YES he should be directed to settings page and that part is done but now after enabling the GPS from this page the user should redirect to the app again but unfortunately there is no way as there is no back button in the setting page.. Please suggest what I can do in this regards?
As far as I know, the only way to open your app (aside from user tap your app or a related notification) is to do some custom url handling. but unfortunately you can't do such a thing. The other thing you can try is to:
Setup a background thread when your app goes to background
check for location service availability
if it changed to your desired value, open a custom url which in turn will open your app (you should register for hat particular url in your info.plist and such)
but There are some things to keep in mind:
Such Behavior will almost surely get your app rejected by Apple.
in iOS 9+ Apple added a new feature that will help you in this particular problem. when an app gets opened from another app (settings.app for you here) it will add a Back to xxxx in place for network indicator to help user get back were he was.
So, IMHO leave the user experience be as it is for all other applications and don't worry about how he would get back to your app.

Google Plus iPhone API sign in and share without leaving app

I have integrated the Google+ API in my App for login and sharing posts. Problem with it, is that everything requires you to leave the app and then come back (it uses URL schemes for this). This is not the expected behavior. I would like to know if there is a way to directly open up the login dialog within the my app it self without going to safari.
I really want to avoid going back and forth between safari and my app.
I just implemented same thing for my application. I have used Google's Sign In SDK. it will present Webview controller inside your app and let you login with your account, after that it will dismiss the Webview controller and call a delegate to get info for user.
Please read and follow the steps from this link,
https://developers.google.com/identity/sign-in/ios/
hope it answers the question.

Inter app communication on IOS

In IOS, it is possible to launch another app from your app using a URL scheme.
But is it possible to have it then return to the calling app if the home button is then pressed?
What if Guided Access is enabled?
No sorry, The Home button will always lead to the users home, there is no way for developers to override that.
You can however have a button in the "called" app that will take the user back to the app that opened it. Facebook does this when going back and forth between their main app and their messages app.
edit Good answer from #shim about guided access in the comments. Basically if its on, you won't be able to leave the app so it doesn't do any good with this problem. /edit

Resources