swift open link in safari/app store - ios

I have a simple iOS app and I'm in the process of developing a pro version of the app. I will then add a hyperlink to the existing app that will point to the url of the pro app in the app store. So is there any recommended way to do this so when the user taps the link, they will be forwarded to the pro app's page on the app store?
Will the user be redirected to the app store if I simply use this piece of code?
UIApplication.sharedApplication().openURL("http://itunes.apple.com/myappname")

As Far As I know, there's no longer
itms-apps://
instead of the regular http://
so the best way is to use this line of code, watch that I've put it in NSURL because you can't past a simple String. Other than that you can use ! at the end or better way is to use IF LET ...
UIApplication.sharedApplication().openURL(NSURL(string: "https://itunes.apple.com/us/app/24-s-wt-h-plyqzyh-hyhydh-smqry/id897282272?ls=1&mt=8")!)

UIApplication.sharedApplication().openURL(NSURL(string : "itms-apps://itunes.apple.com/app/developerName")!)
With this one I couldn't open my app page on the App Store then I went to my iTunes page on Safari, copied my home page uri and pasted it to related code. And it works perfect!
Just copy your iTunes page on the internet and paste it!

Related

Branch.io redirects to app store only though app is already present in device

In my one of the apps I have implemented branch.io.
I have read each and everything and settled my account accordingly.
Now what I want from branch.io
1) If app is present in device it should open on the click of
marketing url.
2) If app is not present in device then it should redirect to app
store application page.**
What is not working
1> Though app is present but it is not opening my app. From same url
schema I can open my app from safari browser "appname://" but not able
to open from link of branch.io. It always opens app store page.
Please help me.
Thank you
Alex from Branch.io here. What you want from Branch is exactly what we do, so let's figure out what is going wrong!
This sounds like a Universal Links configuration issue. If you did not get Universal Links set up fully, then Branch links will redirect to the App Store. If you haven't yet set up Universal Links, go ahead and complete this guide to get started. If you have set up Universal Links, we have a troubleshooting guide you can run through to catch most issues.

Facebook App Links don't open my app

I have added my URL scheme to my .plist.
I have manually tested the scheme in Safari and confirmed that it launches my app just fine.
I have generated a hosted app links link that uses the scheme.
Nothing except my own URL was entered when creating the hosted app link.
When I tap the link on my phone (with my app installed) it takes me to a page with the text You have reached an implementation detail. It's pretty obvious that Facebook didn't even try to use the URL that I had provided when creating this hosted app link.
I should add that I have successfully created other hosted app links moments before that managed to redirect to webpages and to appstore, so there's nothing wrong with mobile Safari.
Where to go from here?
Edit: My app is, of course, in development.
I was having the same issue until i updated my app settings in the facebook developer site.
In the image for #1 you enter the prefix (even though it says suffix...) for your url scheme (ex: if you use myapp://testing/here, then enter "myapp" into the field)
make sure #2 is flipped to yes
Facebook iOS Settings
This is an old thread, but after spending some time on this I realized that the https://fb.me/... links only open from within the Facebook app on the device. They will not (and are not intended) to open from a web browser. After posting the link in a Facebook group I was able to successfully open my app with it.

Is it possible to have an iOS webapp call another regular app to open? Works with Mobile Safari.

I am working with my web developers that are stuck on a problem with a Web-app we are creating.
The webapp works great, you add the website to your home screen on the ipad, open it and use the website within the webapp interface outside of safari.
The issue is that we have one function that doesnt work, where when clicking a URL link within mobile safari, it calls an external app (Optiscan- a qr code reader), and then when scanning the code, then returns you to Mobile safari.
The question is - is there a way to call a URL that will open an external app, from within a webapp? Similar to how it would work from mobile safari?
If so - i am then wondering if an app can be written that calls the webapp to open. For example if i needed the QR code reader to then re-open the web app and pass it the QR code.
-Dana
In iOS, native Apps can define Custom URL Schemes. If you know the scheme of an App, you can simply open it by clicking on a link like Launch Facebook App. This should launch the Facebook App for iOS if installed.
There was a crowd-sourced list of known URL schemes on akosma.com but they seem to have some problems and the list is not available as of writing this. If the URL scheme of the App you need to open is not public, try contacting the developer and ask for it. I'm sure if you ask kindly, he will help you ;-)
Edit: Almost forgot to say, opening Apps like this won't return to your Web-App magically. That's something the developer of said App would have to implement.
Edit 2: I found another website that has many custom URL schemes in it's database: http://handleopenurl.com. It does not have a URL scheme for Optiscan but for other QR Readers, maybe this will help you.

How do Apple detect if an iphone app is installed when clicking on a pure html link?

I am trying to detect if my ipad app is installed on a device when visiting my website, in order to suggest different action to the visitor.
Thanks to this post :
https://stackoverflow.com/a/8310348/1128754
I found that the "store" application on iphone seems to have achieve to detect if the app is installed on the device. When you click on store links, it launch the app instead of going to the mobile web version.
For example, if you go to :
http://store.apple.com/xc/anythinghere
with an iphone on which apple store app is installed ( http://itunes.apple.com/app/id375380948 )
it automatically start the store app, instead of the web page.
I tried to follow the stack call with mitmproxy but safari doesn't seems to ask query before launching the app.
So, I guess they did custom url scheme recognition, with http:// links.
Do you think it is possible?
This is done with URL protocol handlers:
http://www.iphonedevfaq.com/index.php?title=URL_schemes#URL_Protocol_Handlers
You cannot detect if an app is installed from HTML, but you can launch an app. For example, the popular game "Doodle Jump" can be launched by going to doodlejump://, but if you don't have it installed, the link won't work. As mentioned, this is done with a custom URL scheme and needs to be coded into your app.

How to force an iTunes URL to open in Safari on the iPhone?

I have the following URL which links to the product page of a Mac app. I'd like to provide this URL inside my iPhone app. However, it always launches the App Store and subsequently can't display the product because it's not an iOS app. How would I tell it to open in Safari? Is this even possible?
http://itunes.apple.com/us/app/appname/idxxxxxxxxx
Haven't found an answer, so opted for directing to Appshoper URL instead.

Resources