I want to open my ios app using URL schemes. I am able to open app using this.
But I want if app is not installed then app store should be opened where user can download app.
Is this possible? How can I do that?
EDIT
Explaining question step wise:
I have a mail in my inbox with a url.
I click on URL then
i. If app is installed in phone, app will launch.
ii. Otherwise app store will be opened to download app.
Thank
I handled it via my server side code:
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("com.myapp://");
setTimeout(function() {
if (!document.webkitHidden) {
location.replace("https://itunes.apple.com/app/xxxxxxxx");
}
}, 25);}
else if ((navigator.userAgent.match(/android/i)) || (navigator.userAgent.match(/Android/i))) {
location.replace("https://play.google.com/store/apps/details?id=packagename&hl=en");}
else {
location.replace("http://www.example.com");}
I put this in my www.mysite.com/download page & share this url via campaigns.
What you're describing is called Deferred Deep Linking (Deep Linking refers to using a link to open your app, even directly to a specific piece of content, and Deferred means that it works even if the app isn't installed first).
Unfortunately there's no native way to accomplish this yet on either iOS or Android. URL schemes don't work, because they always fail if the app isn't installed. Apple's new Universal Links in iOS 9 get closer, but you'd still have to handle redirecting the user from your website to the App Store
A free service like Branch.io (full disclosure: they're so awesome I work with them) can handle all of this for you though. Here's the docs page covering exactly how to create email links like you described: https://dev.branch.io/features/email-campaigns/overview/
If your App is not installed in device then, you can open app store using below lines of code:
NSString *iTunesUrlofApp = #"itms://itunes.apple.com/us/app/apple-store/...";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesUrlofApp]];
Try below code:
if([[UIApplication sharedApplication] canOpenURL:url]){
// Means your app is installed, and it can be open
[[UIApplication sharedApplication] openURL:url];
}
else{
//Your app is not installed so, Open app store with your apps iTunes Url
NSString *iTunesUrlofApp = #"itms://itunes.apple.com/us/app/apple-store/...";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesUrlofApp]];
}
After iOS 5 you can also use https:// to avoid redirections.
Edit:
Check the link to open app from url if installed: Universal links to open app from Url.
Related
I installed Meeseva app on my device. When I try to open it programmatically it's not opening.
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"Meeseva App://location?id=1"]]) {
NSString *mystr=[[NSString alloc] initWithFormat:#"Meeseva App://location?id=1"];
NSURL *myurl=[[NSURL alloc] initWithString:mystr];
[[UIApplication sharedApplication] openURL:myurl];
}
When I opened fb, twitter, google+ and etc... all are opening successfully.
Can any solve this this issue?
App link is
https://itunes.apple.com/in/app/meeseva-app/id1121539928?mt=8
Is there any another way to open installed app programatically?
If your app can receive specially formatted URLs, you should register the corresponding URL schemes with the system. Apps often use custom URL schemes to vend services to other apps.
Hence "Meeseva" app might not have created a custom url for their app. So you can't do anything for it.
As mentioned above the apps which want to provide support for url schema then they have to create a custom URL schemes.
You need to find out what the correct URL scheme of the Meeseva App is. Meeseva App:// does not seem to be a valid URL scheme as it has a space in the middle.
For example the Google Maps URL scheme is comgooglemaps://, not Google Maps://
Usually developers make their URL scheme public in their documentation. However this is a feature that needs to be implemented and apps don't support this "out of the box". If the developer did not implement this, the app can't be opened via link.
Alternatively it is possible that the app reacts on "universal links". That means if there is a website for the app, iOS might ask you whether to open that website in the app or in Safari. In that case you could simply link to the website and let the user decide how the link should be opened. However, again, this needs to be implemented by the developer. If the app does not support universal links either, there's no way for you to open the app at all.
I'm building an app where the user can open the IMDB app to a particular actor or visit that page via Safari if they don't have the IMDB app installed.
NSString *imdbWebLink = #"http://www.imdb.com/name/nm1090683/";
NSString *imdbAppLink = #"imdb:///name/nm1090683";
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:imdbAppLink]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:imdbAppLink];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:imdbWebLink];
}
The above code works fine but I would like the IMDB App back button to return the user to my app. So I set up a URL type (named bundle identifier) and a custom URL scheme (named bundle identifier with the periods removed) in info.plist for the app. I then modified imdbAppLink following x-callback-url protocol:
imdbAppLink = #"imdb://x-callback-url/name/nm1090683/?x-success=custom_url_scheme&x-source=AppName";
The IMDB app opens correctly to the requested page but the Back button takes the user to the IMDB home screen and not to my app.
I've been researching this for hours here on Stack and on Google to no avail, yet lots of interesting dead ends. As Princess Leia once said, "Help me, Obi-Wan Kenobi; you're my only hope."
If you visit the imdb link above, you will see some of my non-iPhone work, but suffice is to say that I would prefer for the user to return directly to the app rather than indirectly with a bunch of Home button clicks.
Thank you in advance for any help.
X-callback-url has to be implemented in the app that you're opening, otherwise it will not work.
Do you have any reason to believe that IMDB supports it? I don't see IMDB listed at http://x-callback-url.com/apps/.
I hope this is not asked before, I've searched and not sure those are the answers that I want (iPhone apps: Can I open an app from a link in a website? and Apple URL Schemes). Plus I haven't developed my website yet either, so I'll probably need some tips for that too.
My goal is to develop a website AND an iphone app that can eventually connect together. For example, something like Yelp or YouTube: you can go to their website on phone and they will tell you that either you can download their app or you can launch their app from there. Also IF they launch the app, the app will be displaying whatever they were looking at (maybe the same page, etc.)
So my questions are:
1) Can you give me suggestions regarding the development flow? (App first or website first, framework, etc.)
2) How do you actually connect them and make your app to go to the correct view?
Thanks a ton!
1) Can you give me suggestions regarding the development flow? (App
first or website first, framework, etc.)
I recommend you start with what you do best, so you're more productive. Unfortunately I have no site hint to give you, sorry.
2) How do you actually connect them and make your app to go to the
correct view?
You can use this for open any website:
NSURL * URLMyWebSite = [NSURL URLWithString:#"http://www.google.com"];
[[UIApplication sharedApplication] openURL:URLMyWebSite];
For open your app, you need enable URL Scheme, only add URL Type into plist:
After this, you can open your app:
Open My First App
And you can send parameter:
Open My First App
Use HelperLibrary for parse query string into NSDictionary.
Other app can open your app:
NSURL * URLMyFirstApp = [NSURL URLWithString:#"myfirstApp://login?username=rondinellimorais&password=1234"];
if([[UIApplication sharedApplication] canOpenURL:URLMyFirstApp]){
[[UIApplication sharedApplication] openURL:URLMyFirstApp];
}
I am trying to share a link via Whatsapp and have read many tutorials as well. I am able to share my link successfully but the problem is that user doesn't come back to my app after sharing on whatsapp.
Here is the code I am using to share:
NSString *referralLink = [NSString stringWithFormat:#"some link here"];
NSString *textToSend = [[NSString stringWithFormat:#"whatsapp://send?text=%#",referralLink] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *whatsappURL = [NSURL URLWithString:textToSend];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
I know that I have to use URL Scheme to achive this and I have used it too. But I am not sure that I am using it in correct way.
Here is the screenshot of my .info file.
Behind the black bar, I have entered the bundle identifier. i.e com.abc.myapp
This is default behavior in iOS, only if the app developer of the app you are calling allows an option to send the user back to calling app will it work.
WhatsApp does not have such a feature and this is therefore not possible.
Also you should not use the whatsapp: url scheme in your apps info.plist. Doing this will make any app calling whatsapp: to open your app.
you should give your own url scheme(a unique identifier), probably your AppName. You are not supposed to use whatsapp
Now IOS 9 Do support the Apps to come back to the app when they are invoking any third party app being called using OpenURL scheme.
You can make a OS version based support at this moment unless you come to minimal support of IOS 9 for your application.
I wanted to open Facebook and Twitter apps from my app. I find very simple way like:
NSURL *url = [NSURL URLWithString:#"fb://profile"];
[[UIApplication sharedApplication] openURL:url];
And there are many others url for open different page of Facebook. How can I check if Facebook app exist on iPhone? What happens if the application is not install on device? Now I try to use this method on iOS Simulator but nothing happened. It's bug of iOS Simulator? Only tomorrow I will have chance to check on device.
You can check if a URL would likely open ahead of time using the canOpenURL method of UIApplication.
http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/canOpenURL:
Also! You can pass values for the facebook page you'd like. This Stack Overflow includes a link to a wiki with all the variations:
Launching Facebook and Twitter application from other iOS app
If you know the URL scheme that the other app is using (e.g. fb:// for the Facebook app), you can first ask whether your UIApplication object can open such URLs in the first place, with canOpenURL:. You can use this, for instance, to decide whether to display a link at all, or whether to direct the user to Safari (with a normal web URL) instead.
As third-party apps cannot be installed on the Simulator as far as I know, the only way to test compatibility with them is on an actual device.