How do I avoid the "Open this page in 'appName'" alert from appearing in Safari for iOS? - ios

I am creating a flow that:
1) takes the user from my iOS app to my website through Safari
2) and then navigates back into the app via javascript
However when I try and redirect the user back to my app from my site using url schemes, i get the familiar "Open this page in 'appName'" alert.
Is there a way to avoid this alert from showing up? Is there some way to whitelist my website as a source for my app to allow me to direct the user back to my app w/out any alerts?
It seems like it might be possible with Universal Links, but I am wondering if there is a simpler way to do so.
EDIT: I should have mentioned that I have the unique requirement that I need to use Safari. I am processing donations in my app, and Apple requires you to go this through Safari and not a webview. Any ideas? –

You can achieve this using webView instead of Safari,so that
control will not go out of the App.
Now the problem is how to get the click from webView, for that you can
use this approach
How to invoke Objective C method from Javascript and send back data to Javascript in iOS?
I have integrated this approach in my App so this approach will work for sure. It feels like you are in APP & some times it will diificult to differentiate between WebPage & native page

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.

ios make universal links open only from specific websites

I implemented universal link to my iOS app. It directs user to application if url has this "www.websiteurl.com/suburl/*.com" pattern.
I want this work only if user click this url from google search result. If user is already in website I want to open url in website either not open the application. How can I prevent it?
edit: I implemented Support Universal Links documentation.
Yes, this is possible, but I don't recommend it. If the user has the app installed, it seems like you should want to open the app as soon as possible since it is a much better experience. Anyways, here's my solution.
Option 1
Short answer: Wrap your website links in javascript
Why? according to the Apple standards of Universal Links, a link must be clicked on by a user to trigger the Universal Link, therefore if you set up all of your links on your website to be handled by javascript, the app will never open from inside your website.
Therefore, change
Link
Into a javascript call
Link
And open the link from javascript
function clickLink(link) {
window.open(link);
}
Option 2 (Better option)
Use a third-party like Branch links for all of your deep linking so that you can pass more context from web to app allowing the user to continue the same experience on mobile that they were just having on the web. Native is a much better experience 99.9% of the time and it converts users at a much higher rate than web.

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.

Opening a website form in an (objective C) iOS app embedded browser, and then closing the browser upon submitting the form

Our web app has a certain complicated form that will take too long to build out as part of our native (Objective C) iOS app. I was hoping that we could instead open the form from the native app in an embedded browser (a browser built into our native app), and then upon submitting the form in the embedded browser, close the browser and return to a native app screen. Is this technically possible? If so, how can it be done?
If it isn't, then is the following possible? in the native app, have a button to open the form in a non-embedded browser (e.g., Safari), and then automatically close the browser when the form is submitted and return to the native app.
BTW, a co-worker told me that the former is possible with native Android (Java) apps.
Amin Negm-Awad's suggestion seems like the easiest option, but there's also the WebViewJavascriptBridge, to send messages back and forth from Objective-C and Javascript in a UIWebView, it might be worth checking out https://github.com/marcuswestin/WebViewJavascriptBridge
Haven't used it in a while, though.
(this feels like it'd be better as comment but I can't comment yet)
You can have a web view in your app displaying the form. Define an URL scheme for your app and send the form to the app:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW1
But you should really recheck, whether you want to use a web form inside your app.

Pass data from App to Safari Web page back using Universal Links in iOS

As per Apple documentation ,Support Universal Links , we can move control from Safari to App using Universal Links.
In my app, when user is in doing some actions in web pages, only for particular action I want to move control from Safari to my App. Then I want to do some action in App and then again want to move control to Safari's web page, from where I had moved control to App , with output data that got generated in App by using web service.
I know user can go back to Safari from App by clicking on breadcrumb button in the status bar. But I want to achieve this programatically.
How can I achieve this.
Just use openURL in your app to open the web page you want to return to in Safari. The Universal Link will not be in effect in this case, since you're in your app and iOS will correctly deduce you just want to open Safari.
configuring Universal Links does not require you to include the query part, which means you can still use it to pass data (in both ways)
You registered http://acme.com/foo/bar in your apple-app-side-association
You can use openURL to open http://acme.com/foo/bar?data=xxx and your webpage can process the data in the query part of the URL

Resources