I used to have a UIButton that would load an URL in the form of itms://example.com this when pressed would load the relevant item within the AppStore application on iOS (rather than in the browser).
However that is no longer working for me. If I switch the URL to https:// then the relevant page opens in the browser but if I use itms or itms-apps then it does nothing. Any ideas why or if there’s a new way of doing this?
The use case is to refer people from one app to download another from the AppStore.
Using the http link should open directly into App Store app via universal links.
// open Google Earth in the app store
UIApplication.shared.open(URL(string: "http://itunes.apple.com/us/app/google-earth/id293622097?mt=8")!, options: [:], completionHandler: nil)
If you wish to keep the experience inside of your app, then use SKStoreProductViewController as pointed out by rmaddy
Related
I have a working universal link that works when used by another app. eg. if I write the link in notepad it will open app the app. But when I call the following inside the app that the universal link links to, it will open in safari. canOpenURL returns true.
have set up this .well-known/apple-app-site-association and also the correct intent-filter. I think its working because the links open the app when clicked outside of the app.
let url = Foundation.URL(string: "https://workingdeeplink.com/")!
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
This is expected behaviour. When an app passes its own universal link to open, iOS will open that link in Safari.
The purpose of this is to allow a fallback when an app cannot handle an incoming link. The logic for handling an incoming link is typically something like:
Parse the incoming link
Determine if the app can handle it
If it can, then handle the link (e.g. select a specific view or take some action)
If it can't, pass the link to open so that the user is redirected back to the web site, where the link can be handled.
This avoids the situation where a deep link opens your app and then nothing happens or an error is shown (because the app can't handle the url)
There shouldn't be a case where your app tries to open a deep link it can handle; it can simply bypass then whole deep link process and take the action that would result directly.
I would like to redirect to the app-store to a specific app, using its ID upon receiving a button tap. I have tried all the answers here on stack overview however none worked for me, they are most likely outdated such as these:
Open AppStore through button, Launching App Store from App in Swift, How to link to apps on the app store
I tried the following URLs, however I get false via UIApplication.shared.canOpenURL(:_):
"itms-apps://apple.com/app/{appId}"
"itms-apps://itunes.apple.com/developer/{appId}"
"itms-apps://apps.apple.com/cz/app/{developer}/{appId}"
How to currently go about redirecting to App-Store? Can this still be done via URL, or do we have to use the StoreKit exclusively?
Thanks in advance
if let url = URL(string: "itms-apps://apple.com/app/id\(appid)"),
UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
Scenario is user will get a link to his email. If user clicks on the link, If app is already installed, app should open and if app is not installed it should redirect to app store.
I've seen deeplinks implementation, but I believe it needs some more implementation in backend too. Can any one help on this?
Redirect to application if installed, otherwise to App Store
gone through this. Is there any better way?
added gif for one more scenario:
in the below gif, from email to app it navigates directly? how?
I'm assuming the link you want to pass by email is an https link. If that's the case, for iOS to be able to redirect it to your app, you'll need to implement universal links. This implementation requires you to register the domain you want to respond to on your entitlements file and add an apple-app-site-association file to your backend. This way Apple can verify the domain you're trying to respond to is really yours.
As a result, when the app gets installed, it can be invoked by your domain links via deeplinking.
Now when there's no installed app able to respond to a specific https domain link, the system will simply open it on a web browser. Consequently, you cannot force iOS to open such links on AppStore directly. What you can do is to check whether the running device is iOS when your website gets accessed and ask the system to show your app on AppStore.
And to request iOS to launch AppStore from a website you can use itms-apps:
const iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
if (iOS) {
// Just replace `https://` with `itms://` on your app's AppStore link.
window.location.href = "itms://itunes.apple.com/us/app/google-maps-transit-food/id585027354?mt=8";
}
// In this example I'm redirecting to Google Maps app page on AppStore.
Note: This is just a simple example used to demonstrate the concept. For a real application, you may want to use a device detection library for browsers, like mobile-detect.js
My suggestion is check iOS version
here Example
let url = URL(string: "www.stackoverflow.com")!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
I am trying to integrate More Apps button inside my app. When user press this, I want to navigate to App Store and open my developer's app page. Expecting to work iOS 8 and above. If anyone did this before, please give me solution. Thank you in advance.
This can be done by simply having the app open a link. Now this link depends on your developer account. I cannot tell you what your link will be. However, it will look something link this:
https://itunes.apple.com/us/developer/id(some id here)
Note that the id is NOT your developer team ID. I really don't know what this id is. You can find it by navigating to one of your apps on the website version of the App Store called iTunes Preview. Simply go to google and search up one of your app's names like so:
AppName by Muzammil
Once you have opened this page, you will see the link "more by this developer". Click this, and copy the link of that page. Then you can just have your app open that link to show your list of apps on the App Store.
Here is the code to open a link just in case your need it:
let yourDeveloperURL = URL(string: "https://itunes.apple.com/us/developer/id(some id here)")!
UIApplication.shared.open(yourDeveloperURL, options: [:], completionHandler: nil)
Hope this helps!
First of all, I know how to make custom schemes in iOS and I know how to open my app from a website using a javascript setTimeout method.
I have an app that uses custom URL scheme and it is working great. What it does is, it sends a http://testsite.com/QueryStrings message to other users in the contact list (predefined) and on clicking those web links in the sms, these things happen:
Open the link in Safari
Open the app if installed with custom url using setTimeout
If not installed, move to the normal website page
What I wanted actually is to open my app directly from SMS if installed but for that I have to send my custom url scheme in the SMS, that is not an option because if app is not installed then this SMS wont work so a weblink is the only option for now.
Today, I installed SoundCloud and accidentally noticed this thing is that when http:// m. soundcloud .com /... url is sent in an SMS and on clicking the link it opens the app (if installed) directly not the Safari (Strange for me).
So I was wondering how come their app open from a web link without opening the Safari. I googled it around but I couldn't find a solution to my problem. I am attaching a screenshot too from my mobile where press and hold on the link in the messages app give Open in "SoundCloud" option as well. So how SoundCloud registered a http link to be handled automatically in the app. Please help guys
Screenshot of SoundCloud Open
The answer to this problem is using Associated Domains (But after 9.2 we have to use Universal Links to achieve this).
Before Universal Links, the primary mechanism to open up an app when it was installed was by trying to redirect to an app’s URI scheme (registered in the app’s PLIST like so) in Safari. This put the routing logic in Safari, but there was no way to check if the app was installed or not.
iOS 9 Universal Links were intended to fix this. Instead of opening up Safari first when a link is clicked, iOS will check if a Universal Link has been registered for the domain associated with the link, then check if the corresponding app is installed. If the app is currently installed, it will be opened. If it’s not, Safari will open and the http(s) link will load.
Functionally, it allows you have a single link that will either open your app or open your mobile site.
Configure your app to register approved domains
Registered your app at developers.apple.com
Enable ‘Associated Domains’ on your app identifier
Enable ‘Associated Domain’ on in your Xcode project
Add the proper domain entitlement
Make sure the entitlements file is included at build
Configure your website to host the ‘apple-app-site-association’ file
Buy a domain name or pick from your existing
Acquire SSL certification for the domain name
Create structured ‘apple-app-site-association’ JSON file
Sign the JSON file with the SSL certification
Configure the file server
Apple launched Universal Links in iOS 9.0, which moves the app routing into the OS so that developers don’t need to worry about doing the routing in Javascript.
Receiving Universal Link URL in the App
URI schemes received the deep link URL through openUrl in the App Delegate. Universal Links receive their data via a different code path: continueUserActivity. This new delegate method is used for a number of app transitions, ranging from Spotlight to Universal Links, and will likely see a couple more use cases introduced in future OS versions.
Below is a snippet of code that you can use to retrieve the full Universal Link URL that opened the app.
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSString *myUrl = [userActivity.webpageURL absoluteString];
// parse URL string or access query params
}
return YES;
}
Source: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9