Select the app that will load the map - iphone

Im opening a map like this:
NSString *urlString = [NSString stringWithFormat:#"http://maps.google.com/maps?q=%#,%#", destLat, destLong];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
Is there any way to choose with which app will open the map? For example, Safari, or the maps app, or Tom Tom app...

Yes, you should use one of the iPhone URL schemes. There is a pretty hefty list available here.
Note that you should first check if the application you want to launch is available before using a certain URL scheme.

If Tom Tom exposes some url scheme you can try that one. Otherwise the default url scheme handlers are "hard coded" to the system and you can't override / change them i.e. "http:" will be always opened by Safari except for "maps.google.com" domains, etc.

Related

Problems open AppStore programmatically

I'm having problems opening the app store (to suggest an app update).
This is what i'm doing:
NSURL *url = [NSURL URLWithString:#"macappstore://itunes.apple.com/app/id[my_id]?mt=12"];
if ([[UIApplication sharedApplication] canOpenURL:url]){
[[UIApplication sharedApplication] openURL:url];
}
canOpenURL is returning false, also i tried without the conditional but it doesn't work.
In addition i tried to use NSWorkspace instead the openURL method in UIApplication but i'm having compilation errors, surely this are dependencies issues but i couldn't find Cocoa.framework and neither AppKit.framework to add one of them to the binaryLibraries of my project.
For iOS, you should be using the prefix itms-apps:// instead of macappstore://. This will link you directly to the App Store app, instead of through a Safari redirect (as http:// or https:// will do).
Lots more on this topic covered here:
How to link to apps on the app store

Open itune link in app store?

My application is in 3 languages, i want to open app store on button click and link is my another application. But when i am sending link to app store , its always opening US market with English description. when i am using browser its going correct. Where i am going wrong.
-(IBAction)Button_us_itune:(id)sender{
NSString *ituneLink =#"https://itunes.apple.com/us/app/My_application/AppID?mt=8&ign-mpt=uo%3D4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:ituneLink]];
}
-(IBAction)Button_fr_itune:(id)sender{
NSString *ituneLink =#"https://itunes.apple.com/fr/app/My_application/AppID?mt=8&ign-mpt=uo%3D4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:ituneLink]];
}
-(IBAction)Button_du_itune:(id)sender{
NSString *ituneLink =#"https://itunes.apple.com/de/app/My_application/AppID?mt=8&ign-mpt=uo%3D4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:ituneLink]];
}
It is might be because you are using/Logged in US store.
Actually it's pretty easy. You have two mistakes:
You are using country code in the links. i.e. you are mention exactly what store you want to open. This is bad because on some cases the user would open different store than the one you need. If you ask for US and user registered for another one you would lose him.
You probably can't tell which store the user is register to. So even if you create the the right link you can never tell which function to call (there is no API to know where the user is registered according to my knowledge - you can just know where he is or his language settings).
So, You could just remove the country code. i.e:
NSString *ituneLink =#"https://itunes.apple.com/app/My_application/AppID?mt=8&ign-mpt=uo%3D4"
But even then you would probably have problems with the link itself on some cases and in some OS versions.
I suggest you use a simple library called iLink that would figure out everything (at run time) and create the link you need that would work always. It also have a great feature that would prompt the user for an update if there is one on the store.
You are giving denmark app link. And I think you are logged in with other country.

how do I open iphone apps via phonegap

I want to open iphone apps like Contacts and Calendar from within my phonegap app, I don't mind that doing so will put my app in the background. I can open the browser and using window.open but how do I open other apps?
eg window.open("contacts://", '_blank'); doesn't work
The only way that one app, PhoneGap-based or otherwise, can cause another app to launch is to open an URL that uses the target app's custom URL scheme. So, if the Contacts app supports some custom scheme, you're in luck. If not, you're out of luck.
You are going to need to write a custom phonegap plugin so that you can access custom methods you write in objective C.
The official phonegap documentation is here.
I'll briefly explain how you will do this.
In your javascript you will call this code :
PhoneGap.exec("OpenMailAppPlugin.openMailApp",parameter1);
In objective C you will create a new file OpenMailAppPlugin class. Read the link above for exact instuctions, but the important method will be soemthing like this.
-(void) openMailApp:(NSMutableArray*)paramArray withDict:(NSMutableDictionary*)options {
NSString *parameter1 = [paramArray objectAtIndex:0]; //recieves information from javascript function
NSURL* mailURL = [NSURL URLWithString: #"mailto:%#?cc=bar#example.com&subject=Greetings%20from%Cupertino!&body=Wish%20you%20were%20here!",paramter1];
[[UIApplication sharedApplication] openURL: mailURL];
}
additionally, you may be interested in sending information back to your phonegap application. You can do this by injecting a javascript call that sends parameters. In your objective C function you would do something like this.
NSString * jsCallBack = [NSString stringWithFormat:#"myJavascriptFunction('%#');",parameter];
[self.webView stringByEvaluatingJavaScriptFromString:jsCallBack];
As previously answered, using a URL scheme can work. If you have several apps and you want to be able to open one from the other, then it's really simple when using PhoneGap build: you just need to add the URL scheme to your config.xml file, eg:
// In config.xml
<gap:url-scheme>
<scheme>app1scheme</scheme>
</gap:url-scheme>
Then from your other app you'll just have a link to app1scheme://, eg simply
Start App1
Here is the list of all the iOS/iPhone app url
Video - video:
Music - music:
Youtube - youtube.com
iTunes store - itms:
iBooks - itms-books:
App Store - itms-apps:
Mail sending - mailto:
Telephone - tel:
More can be found at this outdated link
http://www.wiki.akosma.com/IPhone_URL_Schemes
Look at this on how you can implement your's url
https://appurl.org/docs-handling-android
Need to use a plugin, unfortunately you need native ios code:
This one works:
https://github.com/phonegap/phonegap-plugins/tree/master/iOS/ExternalFileUtil

how to open app store with in our ipad or iphone application?

Hi i want to open app store with in our application with the specific publisher search or specific application types..on clicking of button..let's say More App's...
You can get the appropriate URL to your app here:
http://itunes.apple.com/linkmaker
If you enter the name of your company the linkmaker will provide an "artist link" that shows all of your apps.
If you use the itms-apps:// prefix the user is sent directly to the
App Store App with the specified app showing rather than the ugly
first-Safari-then-the-App-Store-App shuffle that you get without that
UTI. A la:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
#"itms-apps://yourAppLinkHere"]];
To generate a link that is universal and not specific to an App Store Country do the following
Use
itms-apps://**ax.itunes**.apple.com/app/yourAppLinker
where yourAppLinker is the part of the link generated in (http://itunes.apple.com/linkmaker), as in Matthew Frederick's post, which contains your application name and id
it worked for me
cheers
For IOS7 and later for example:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"itms-apps://itunes.apple.com/app/id547101139"]];

Direct "rate in iTunes" link in my app?

I've seen posts here on Stackoverflow that describe how to allow users to be directed to apps on the app store.
Is there a way to link directly to the rating and comments form in the App Store?
This IS possible using the technique described on this blog:
http://www.memention.com/blog/2009/09/03/Open-Reviews.html
basically you call UIApplication openURL with the following:
NSString* url = [NSString stringWithFormat: #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%#", myAppID];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
To get your app ID before your app is available in the app store, use iTunesConnect to define your new app - give it a name, description, icon, screenshots, etc. Once defined, you can get the Apple ID from the Identifiers section for the app.
EDIT:
Here is a secondary url/method that works:
NSString* url = [NSString stringWithFormat: #"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%#&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8", appid];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url ]];
I believe the difference between the two is that the first technique (itms-apps://) will launch the App Store app directly while the second one (http://) will launch it indirectly via a redirect resulting from the http web URL. This would have to be confirmed; this is only my recollection.
Answers here are outdated.
This works on my end (Xcode 5 - iOS 7 - works only on Device, not simulator!):
itms-apps://itunes.apple.com/app/idYOUR_APP_ID
For versions lower than iOS 7 use the old one:
itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=YOUR_APP_ID
Simple method that I am using is;
-(void)rateApp {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[#"itms-apps://itunes.apple.com/app/" stringByAppendingString: #"id547101139"]]]; }
You can also use SKStoreProductViewController as an alternative. It will open the store in your app. You may like it better than opening another app, especially on iPads.
Thanks to Ahment swift version:
UIApplication.sharedApplication().openURL(NSURL(string: "itms-apps://itunes.apple.com/app/id951334398")!)