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.
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 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.
I am making on Xcode 6.1.1 and application and wanted to have a link that takes you to https://www.instagram.com/naturee/
I added this:
NSURL *instagramURL = [NSURL URLWithString:#"instagram://user?username=naturee"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
form
https://www.instagram.com/developer/mobile-sharing/iphone-hooks/
But it takes me to Instagram application but not a username!
Does anyone know how??
To understand Universal Links, it’s important to first understand deep links.
Deep links are nothing more than the ability to open up an application to a specific piece of app content. It’s akin to linking to a page other than a homepage on a website.
In order to deep link into an app, traditionally a developer had to register a protocol (i.e. instagram:// , twitter:// , facebook:// ) with the operating system when an app is installed. Subsequently, when an incoming request is received on the device to a registered protocol, the operating system launches the associated application, letting it handle the request (link).
This works well enough; however, if a developer has a website mirroring its app content it results in having to effectively manage, maintain, and synchronize two sets of URL schemes, one for the web and one for the app.
Universal Links try to solve this problem by enabling an app to handle incoming https:// requests (regular web requests).
On iOS 9, a user may navigate or click a link to a webpage and if that website is setup to handle Universal Links (and the app is installed on the device), the operating system will intercept the request (without opening Safari if not already open) and pass the request to the associated application.
Universal Links are an easy way to intelligently route web traffic to an application if available. It enables developers to make the app the default place to send web traffic on iOS, using the web as the backup destination if the app isn’t installed.
quoted from this site
You can use Support Universal Links in your application on iOS9.
There is more information on this link
Your code will work if you change ur NSURL by :
NSURL *instagramURL = [NSURL URLWithString:#"https://www.instagram.com/naturee/"];
If you still want to use URL Scheme, there is something wrong with your actual one :#"instagram://user?username=naturee". You can check it by opening safari on your device and past this url scheme. it won't open instagram's naturee's profile.
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 have searched the web and all my books and references but I'm not finding what I am looking for.
Because of the type of app built I need to restrict access to the UIWebView "stuff" if the user has Safari restricted.
Is there a way to check is safari has been restricted on the iPhone and if so examples...sites, references?? I'd like to be able to check and give an alert for those users and for others users just load the pages. Everything is working for me BUT I don't know how to check if it's been restricted.
Thanks in advance.
The best I've found is to use the following:
BOOL safariAvailable = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"http://test"]];
In iOS 6.0 it seems that apple changed this behavior (which worked in 5.x) :(
Only way I've found is to actually try to open the URL, and then watch for resignActive notification on your application delegate. If you fail to get it shortly after calling, then it's likely safari isn't present. Ugh.