I'm developing an iOS application in which I want to provide users with a payment gateway, which is a web page. I'm showing this web page in a WebView.
The payment gateway accepts 2 URL params - success and failure URL, which are the URLs users is redirected to after completing purchase. Redirect is done via JavaScript location.href property and works properly in desktop browser and Android app.
I've set the URLs to let's say tft://redirect/success?id=123 resp. tft://redirect/failure?id=123
I want my app to handle this redirect and show Success or Failure message to user.
I followed many tutorials including Apple's docs.
First of all I'm not sure why Apple docs show scheme without slashes (myphotoapp: instead of myphotoapp:// - does it make a real difference?)
I've registered custom scheme tft and implemented the func application(..) function according to the docs.
Now when the redirect should happen, nothing really happens, the func application is not called at all.
I started development with iOS 12 and recently switched deployment target to 13.5, however, the project structure didn't change (scene delegate missing - is it an issue?).
Can you please give me any direction?
Thanks in advance.
According to https://stackoverflow.com/a/37240425/9046249 custom scheme behaves somewhat wierd. When I switched the scheme to http or https it works like a charm.
Related
I'm trying to use the callback functionality of the URL schemes for Google Maps on iOS.
The way how to do that is documented here.
However, I did not manage to get this to work. There is no additional symbol showing up as described in the documentation.
Is this actually still possible or has this feature been removed?
Independent of my application, I also tested this by pasting the URL scheme in the Safari browser, but it doesn't work there either.
It simply starts the Google Maps app but apparently ignores the callback parameters.
Edit:
This is the URL from the example of the documentation:
comgooglemaps-x-callback://?center=40.765819,-73.975866&zoom=14
&x-success=sourceapp://?resume=true
&x-source=SourceApp
The only difference would be that the success parameter gets the URL of the app you want to open when the user clicks on the callback button.
Check if your application's url scheme has been implemented correctly and that you're specifying a valid callback url (that directs back to your app).
Some links that might be useful:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
I've set up Universal Links on my iOS app using an aliased subdomain of my backend with a scheme like sudomain.mydomain.com. I want users that DON'T have the app installed to be redirected to our page in the App Store rather than hitting some nonexistent endpoint on our server (we don't have a webapp only a mobile backend).
I was thinking about doing something like this:
app.get('*', (request, response) => {
const domain = request.headers.host,
subdomain = domain.split('.');
if ( subdomain[0] === 'subdomain'){
response.redirect('www.linktoappstore.com');
}
...
});
However I don't want this to interfere with Universal Linking for people who DO have the app installed. Are Universal Link get requests sent to my server or does iOS intercept them before that happens?
This should work just fine.
When Universal Links are configured and your app is installed, the device does NOT hit the server before launching the app. This is because iOS caches the apple-app-site-association file when the app is initially installed, and if the URL being opened matches a path defined there, Universal Links kick in. In that situation, iOS completely bypasses any web request and immediately launches your app.
Of course, this means you can't track Universal Link traffic, which can become a major pain point. To work around this, you need something like Branch.io (full disclosure: I'm on the Branch team) to fill in the missing data.
Separately, if you're proxying the subdomain, make sure iOS doesn't see that as any sort of redirect. Otherwise the apple-app-site-association file won't be scraped at all (common Universal Link implementation issue).
The official Apple documentation doesn't seem to specify whether iOS URL schemes are case-sensitive or not.
Can I register myApp and still get opened for someone calling openURL: on MyApp://params?
They are not case-sensitive.
You can verify this by entering both sms:// and sMs:// into the URL box in Safari.
Also, it seems that third-party URL schemes in the Safari address bar now lead to a page not found error. This must be new in iOS 9.3.x, because it did not do this before. Entering the URL into another app (e.g. Notes) and then opening it still works.
Edit: the above hypothesis about iOS 9.3.x is actually a bit more nuanced...
They work if…
You are starting from a blank screen
A page is still loading when you request the custom URL scheme
They do NOT work if…
You are on a webpage that has fully loaded before you request the custom URL scheme
Go figure
I found a lot of tutorials about opening an app by a custom url scheme like:
myappname://
Thats nice but it would be great to open an app by registering the real app domain over the http link like
http://www.myappdomain.com/blablabla
So - for example - if a visitor comes to a webpage (on her/his mobile) it is normally opened in the browser, excepts the installed app is listening to the opened URL and opens itself instead of the browser.
How is this done (i've seen this at another app). Any help would be great. Thanks in advance!
It is a new feature in iOS9. It is explained in the WWDC15 talk Seamless linking to your App.
You could also add a small piece of javascript to each page that opens your custom URL-scheme.
This is my first time create an ios application that required deep linking. I need to create a web service for my custom url scheme for ios in order to publish it online. Please give some pointer on regarding which web service i should use or is there an alternative way to create a deep linking for custom url scheme for iOS. Thanks.
You can do it yourself with any server platform - Rails, PHP, Dot.Net, etc.
Here is a very simple PHP snippet. Replace "myappname" with your app's URL scheme. The param/value query is optional - you can use any other text and parse it in your App Delegate's openUrl method.
if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone OS') !== FALSE) {
// redirect
header("location: myappname://?key=value");
exit();
}
Client use-cases:
iOS Safari, your app installed - will open your app.
iOS Safari, your app not installed - Safari will complain that it cannot open the link.
Another iOS app, your app installed - will switch to your app.
Another iOS app, your app not installed - same as Safari. However, if the other app is implementing UIApplication's canOpenURL: - it may gracefully take the user to the App Store, but it's up to the other app developer.
Any other device or browser - will continue to render the page, where you can add your html including AppStore links.
If you don't want to create the server code, you can use a tool I created for this purpose. You have it here:
http://www.uppurl.com/
It's mainly a short link tool that checks for user device and give him the right url based on his devices. With this tool you don't need to write any server code and it also takes care of different devices, operating systems and browsers.
Take care of Tal answer as latest versions of Chrome has changed the way to open app and now you need to provide a link in different format, they use something like "intent://..."