How can I launch app store from my application - iphone

Im trying to implement button which opens app store application from my app. I use this simple line of code, which opens safari but not app store application.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: #"http://itunes.apple.com/sk/app/tweetie-2/id333903271?mt=8"]];
I dont know whats wrong, is the URL format correct? I was following this document.
All related questions in stackoverflow are outofdate I suppose.

If you want to bypass Safari, change 'itunes' in the URL to 'phobos'. Note that this will fail in the simulator, but most definitely works on the device.

According to the documentation, iTunes affiliate links have to process several redirects in order to wind up in iTunes. Follow the example to create an NSURLConnection, set yourself as its delegate, and use the string it ends up with to open with UIApplication.

Related

launching the facebook app to a group from iOS

What I am looking to do is launch the facebook iOS App from my iOS App. I can do that with fb://URL but what I need to do is start it off in a facebook group page. It seems like all I can do is launch the app to the users news feed. I have no problem launching safari from my app direct to the group using the URL you normally would use (https://www.facebook.com/groups/group_name) but I would rather have people end up in the iOS app not safari.
I expect I might have have more luck using the facebook API inside my program but think its will be less maintenance in the long run if I let my users just use the official app for being a part of our group.
You are already aware of the existence of the fb:// url scheme, which is the way to go.
calling it goes like this :
NSURL *theURL = [NSURL URLWithString:#"fb://<insert function here>"];
[[UIApplication sharedApplication] openURL:theURL];
In the place of <insert function here>, you could use the following ways to open the facebook app straight to a group of your choice (note that you must use the group id rather than its name):
fb://group/(fbid)/members
fb://group/(initWithGroupId:)/members
fb://groups
The last one opens to the groups overview (which you probably do not want), only added that for completeness.
Akosma has an overview of a great deal of app url schemes for ios here

Open and close url in safari using objective-c program

I have to open a URL in safari... and after doing some work on safari I have to close the safari...
my code is as below.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strPageUrl]];
Actually I have to share video on myspace.. if user has shared the video then I have to close safari and need to activate my application again.
I want to do something similar facebook SDK login with safari..
Please help me how to open this
custom url schemes work only one way... Like if you opened safari from your application then you can't return back to your application unless the second application is also yours and you have implemented another custom url to return back to your application. Since safari was made by apple so it does not have info regarding your application.
I am not exactly sure what you are trying to achieve but you can try out UIWebView for requirement if it helps.

Opening spotify app from my iphone app

I'm pretty sure there must be a way to launch spotify iphone app from my own app. I've seen SMP app (share my playlist) doing something very similar when pushing playlist into spotify app.
I guess it should be by using something like:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"spotify://search:muse"]];
As you can see, I want to be able to make spotify search for a specific keyword. The problem is I don't really know the spotify url scheme, if there is such thing available.
I've been searching in the web, in spotify developer website, etc. but nothing comes up...
I have run into a similar need in an app. My solution was to create a client that hits the Spotify API to return either XML or JSON of the search. For instance, if you want Muse, you would hit the API with the following URL:
http://ws.spotify.com/search/1/artist?q=muse
From the XML or JSON, you'll be able to extract the link to the particular artist within their URL scheme:
spotify:artist:12Chz98pHFMPJEknJQMWvI
Chop off the spotify:artist: portion and append that onto a Spotify artist link:
http://open.spotify.com/artist/12Chz98pHFMPJEknJQMWvI
Then, using the Spotify URL scheme and UIApplication, you can open the Spotify app to that particular artist's page:
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:
#"spotify://http://open.spotify.com/artist/12Chz98pHFMPJEknJQMWvI"]];
Note, using URL schemes to access features of another app is generally undocumented and can be a fragile endeavor. If Spotify in the future decides to change anything about this, it will break this functionality without warning.
The quick fix I made was to remove the urlscheme that was added to the original uri.
so you'll be calling the uri directly.
which is 'spotify:artist:4gzpq5DPGxSnKTe4SA8HAU' or 'spotify:track:1dNIEtp7AY3oDAKCGg2XkH'
UIApplication.shared.openURL("spotify:artist:4gzpq5DPGxSnKTe4SA8HAU")
or
UIApplication.shared.openURL("spotify:track:1dNIEtp7AY3oDAKCGg2XkH")
this fix is for the crash when calling the old urlscheme from v6 and above.

Iphone URL schemes : Back to app

I am opening an another app using openUrl of url scheme.Now I want to back to my source app getting some information from target app.Can anyone know how it will be done?
I am able to open other app using apple url scheme but not getting how it will be returned to previous app.I am using following code to open target app.
[[UIApplication sharedApplication] openURL:url];
You can't, only if the app you are opening knows how to app your app, end knows that your app is the one that opened it will it be able to open your app again.
There is no standaard URL scheme that can tell an other app to open your again.
if the target app yours as well, or it is not but it supports calling back out?
If so, you pass it your URL as a parameter:
url = #"otherapp://?return=myapp";
Latest update from iOS 9:
Now apple provide back button by default when you navigate to any app using url schemes.
Here you go:
http://appleinsider.com/articles/15/08/09/how-to-use-the-new-back-button-in-ios-9

Linking to my apps on the App Store

I want to create button that, when pressed, takes the user into the App Store and all my apps are shown.
At the moment the code is
-(IBAction)goReviewTwo:(id)sender; {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://itunes.com/apps/lifevisionstudios"]];
}
But that doesn't work. Any ideas on how to do it?
Your URL isn't correct. Apple's iTunes Link Maker is the easiest and best way to get the authoritative link to your apps, including for App Stores in various countries.
You can also get a link to a page with all of your company's apps the same way, which seems to be what you're looking for. In the Link Maker your company is referred to as the Artist.
Lastly, rather than using http you should use itms, which will send the user directly to the App Store app rather than routing them through a blank Mobile Safari page first:
itms://itunes.apple.com/us/artist/appname/id?uo=4
Edited to add
As noted in Rab's answer, if you remove the /us it should automatically go to the user's local App Store. It turns out that you also need to remove the query string (?uo=4) that iTunes and the Link Maker generate:
itms://itunes.apple.com/artist/appname/
Just find that page in iTunes, right click the link and choose "Copy Link". Paste it into your code. In your case, I think it would be:
-(IBAction)goReviewTwo:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://itunes.apple.com/us/artist/lifevision-studios/id415139916"]];
}
That should look like itms://itunes.apple.com/us/artist/your-name-here/id101010101 . That's your artist page, and shows your various apps. Take off the /us/ and it should choose based on the user's location. Use the link maker mentioned earlier to specify another country's app store (it will swap in /kr/ for Korea, etc.).
You can link to the App Store with a specific query, like your iTunes Name.
This works:
NSURL *appStoreUrl = [NSURL URLWithString:#"http://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&submit=media&term=Anoxy%20Software"];
[[UIApplication sharedApplication] openURL:appStoreUrl];