Is it possible to retrieve the name of the app which will handle a specific URL?
In other apps I saw "Open Link in Safari" and if you click, YouTube or whatever else will launch. I don't really like this behavior and I'd like the get the corresponding app name before calling
[[UIApplication sharedApplication] openURL:[NSURL someURL]];
to set the right button title.
No, that's not possible with the official SDK.
If you really want that you could create a file/database with the most common URL schemes on iOS (check this), then ship your app with it.
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 have two applications and i want to open them from each other (like facebook opens messenger).
After a little search i found that i have to know the url scheme of my app, but i don't know how can i declare it. In my urlSchemes are only facebook's schemes.
var url = NSURL(string: "")
UIApplication.sharedApplication().canOpenURL(url!)
I found that code and as i understand i have to put in the url my urlScheme.
Any help?
Here is a good tutorial on setting up URL Schemes within you app: https://dev.twitter.com/cards/mobile/url-schemes
Incase this tutorial disappears, heres the info:
Configure our Xcode project
Go to Your Target > Info > URL Types
You need to define your custom URL type. Remember, you want to open the app via birdland://, so that will be your URL scheme. We also need to assign an unique identifier to the scheme. Apple recommends that you use reverse DNS notation to ensure that there are no name collisions on the platform, e.g com.mycompany.ios.
That’s it! You’ve configured the app with simple support for the URL scheme birdland://. There is, of course, much more that you can do with Custom URL Schemes. To find out more, check out Apple’s documentation.
Now, to check that our registered URL scheme works, we’ll head out to Safari. Press the “Home” button in the Simulator (or press command-shift-H) to reach the Home Screen. Open Safari.
Next, type birdland:// in the address bar of Safari. Just as you can with http:// URLs, you’re asking Safari to open the “birdland” scheme. Press Go.
NSString *openAppURL = #"yourappname://";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:openAppURL]];
//check if app is installed or not
BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:openAppURL]];
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 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.
I noticed that on the latest angry birds update they added a feature to gift your app from inside the app.
Up till now I knew you can gift paid apps from the iTunes itself. Does anybody know what link should I use to access this mechanism from inside the app itself?
Thanks!
Actually, you'll want your URL to start with itms-appss: if you want it to open in the App Store app, where someone would actually gift an app. This feels more natural than Safari popping up.
// example app id for batman arkham city lockdown
#define APP_ID 459850726
NSString *GiftAppURL = [NSString stringWithFormat:#"itms-appss://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/giftSongsWizard?gift=1&salableAdamId=%d&productType=C&pricingParameter=STDQ&mt=8&ign-mscache=1",
APP_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:GiftAppURL]];
APP_ID should obviously be defined to the Apple ID of your app.
Also worth noting, the URL is case sensitive.
If you watch what happens when you click that button, you can see that it initially makes a request to a redirect script on www.angrybirds.com:
http://www.angrybirds.com/redirect.php?device=iphone&product=angrybirds&type=purchasegift
From there you are redirected to a secure url of the form:
https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/giftSongsWizard?gift=1&salableAdamId=343200656&productType=C&pricingParameter=STDQ
343200656 is the AppleID for Angry Birds.
I have here some step-by-step instructions in how to add a 'Gift This App' button into your app:
Add a button in your XIB and add an action to it.
In your .m add the actions brackets e.g:
-(IBAction)actionName {
}
add this code in and replace APP_ID with the number in the apps web page link for e.g.
itunes.apple.com/au/app/[APPNAME]/id**APP_ID**?mt=8
this is a code e.g:
- (IBAction)actionName
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/giftSongsWizard?gift=1&salableAdamId=**[APP_ID]**&productType=C&pricingParameter=STDQ"]];
}
Hope this helps!