Detect country of iTunes Store in iOS [duplicate] - iphone

This question already has answers here:
How to detect the active iTunes store on the iPhone/iPod Touch/iPad?
(7 answers)
Closed 8 years ago.
In my iPhone app I would like to detect the country of iTunes Store the iPhone user is logged into, e.g. for a user from USA I would like to direct him/her to:
https://itunes.apple.com/us/album/21/id420075073
and for a user who is logged into the Polish iTunes Store I would like to redirect him to:
https://itunes.apple.com/us/album/21/id403037872
I know that I could check the locale (e.g. the language),but it might not always work.
Any ideas how to achieve this?

NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
will get you an identifier like e.g. "US" (United States), "ES" (Spain), etc.
Because you find country means no problem. We hope the iTunes store must be Device country.

Related

iOS iTunes store country

i am wondering if there is a solution to find out, in which country the user downloaded an application.
For example: app x has been downloaded in USA when the user opens up the app, the app will check in which country it was downloaded. In this example the the return would be "USA"
Does any one hase an idea on how to solve this?
If you have any In-App Purchases available, you can read the locale from the SKProduct. As a fallback, use the device's locale.
NSLocale *locale;
SKProduct *baseProduct = nil; // replace as applicable
if (baseProduct) {
locale = baseProduct.priceLocale; // from the user's credit card on iTunes
} else {
locale = [NSLocale currentLocale]; // from user preferences
}
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
NSLog(#"Two-letter country code: %#", countryCode);
There might be a good enough correlation between the iTunes store country and the locale a user sets. This depends on your needs - if this does not suffice, I don't think there is a way to know which actual store an app was downloaded from.
To retrieve that locale, you could use:
NSString *localeIdentifier = [[NSLocale currentLocale] localeIdentifier];
Hope this is sufficient for your needs.
It's not possible to check "which" App Store an app was downloaded.
If you need to do anything location-based, you should look at CLLocation to obtain a user's current location, however it may seem intrusive for the app to ask a user for their location if it's not apparent why it would need the location.
You could also check for the language on a users device, such as en_gb for Britain, dk for Denmark, en_ca for Canada, etc. While this doesn't completely cover when people in some countries have set the language to something else than the countries native language, it's better than nothing.
SKStoreFront, introduced in iOS 13 SDK seems to do the job.
Swift
if let storefront = SKPaymentQueue.default().storefront {
print(storefront.countryCode) // Returns an Alpha-3 country code (USA, GBR etc.)
}
Obj C
[SKPaymentQueue defaultQueue].storefront.countryCode; // Returns an Alpha-3 country code (USA, GBR etc.)
You should be able to access the SKStoreFront instance by adding the StoreKit framework to your project, even if your app does not offer any purchases.

How to list All iPhone Apps By a SIngle developer in iPhone App?

In My Application I want show all my iPhone apps from itunes store in a tableview. If user clicks any one of cell it leads to take to appstore of that application.I know just statically by giving link of each application. As per my need i need to get new apps also after this installation.
You can use the search web service provided by Apple: http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html#searching
I couldn't find a way to search by artist ID for software, but you can still perform a generic query using the developer name.
For example, this would return apps by Gameloft:
http://itunes.apple.com/search?term=Gameloft&media=software&lang=en_US&country=us
Note that it's a query by name,so you can have false positives (apps where the name Gameloft appears but are not real Gameloft apps). You have to check the artistId property for each returned app (in this case, Gameloft's artistId is 282764297).
If you want to open the App Store to a specific app, use the trackId you got from the previous web service and then
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:
[NSString stringWithFormat:
#"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",
trackId]]];
Instead of doing your own table view, you can also use StoreKit to display the apps, and let the user purchase other apps right there.
Just replace 383916386 with the correct id for your developer account.
SKStoreProductViewController *viewCtrl = [[SKStoreProductViewController alloc] init];
[viewCtrl loadProductWithParameters:#{SKStoreProductParameterITunesItemIdentifier: #"383916386"} completionBlock:nil];
[self presentViewController:viewCtrl animated:YES completion:nil];

How to get friends list of twiiter using twitter api on iphone app! [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
how to get email of friends list using twitter api on iphone app.
Hi all, i am try to write app to get friends list of user on twitter, when user login twitter on my app.
I use twiiter api, but i can't do it.
Please help me with the problem. Thanks so much!
If your Twiiter Api has this MGTwitterEngine.h file.Look for getFollowersIncludingCurrentStatus method which give the list of your followers.
Use this Delegate Method from XAuthTwitterEngineDelegate
-(void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier
{
mFollowerArray = nil;
mFollowerArray = [userInfo retain];
}
Sounds like you need to be sending a GET statuses/friends request to the Twitter API.
For more information, you might want to read through that documentation I linked to, or re-ask your question here with more specific details about the problem you're having.

iTunes Music Store Link Maker — how to search from within my app?

I'm writing a music reference app and for each album (pulled from last.fm) would like to link to the ITMS (if the album is in the store).
iTunes link maker web tool http://apple.com/itunes/linkmaker/ is great for getting links for a known album but I need to access it programatically from within my app.
This NSLog blogpost which is from 2003 but was referenced more recently in another question here seems to offer the only solution I've come across so far, suggesting to submit a query to:
phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?
Put "itms://" before it and the link will work in iTunes, put "http://" before it and the link will work in Camino (Safari sometimes spits back a malformed XML error).
The tags that are of importance are as follows:
songTerm - song title
artistTerm - artist name
albumTerm - album name
composerTerm - composer name
term - all fields
The suggestion is that would using http:// rather than itms:// the server will return an XML document of results instead of opening iTunes but either way I am sent directly to iTunes.
Is it possible to get back a list of results?
I am using LinkMaker to get iTunes details about song I am playing.
For that, I found that LinkMaker is able to return json data and also 1 result at a time.
I am using this url to perfom my query :
http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/itmsSearch?lang=1&output=json&country=%#&term=%#&media=%#&limit=1"
Here are parameters you need to give :
> country : store country term : could
> contains artist name, song name, album
> media : music
For exemple, if you want to have details for a song called "One" by "U2" here is the correct URL :
http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/itmsSearch?lang=1&output=json&country=US&term=U2%20one&media=music&limit=1
Then you will receive json data like this :
{
"resultCount":1,
"results": [
{"wrapperType":"track", "mediaType":"song", "artistName":"U2", "itemParentName":"Achtung Baby", "itemParentCensoredName":"Achtung Baby", "itemCensoredName":"One", "itemName":"One", "artistLinkUrl":"http://itunes.apple.com/us/artist/u2/id78500?uo=4", "artworkUrl60":"http://a1.phobos.apple.com/us/r1000/009/Features/32/9a/60/dj.mfynlttx.60x60-50.jpg", "artworkUrl100":"http://a1.phobos.apple.com/us/r1000/009/Features/32/9a/60/dj.mfynlttx.100x100-75.jpg", "country":"USA", "currency":"USD", "discCount":1, "discNumber":1, "itemExplicitness":"notExplicit", "itemLinkUrl":"http://itunes.apple.com/us/album/one/id368713?i=368617&uo=4", "itemPrice":"1.29000", "itemParentExplicitness":"notExplicit", "itemParentLinkUrl":"http://itunes.apple.com/us/album/one/id368713?i=368617&uo=4", "itemParentPrice":"9.99000", "previewUrl":"http://a1.phobos.apple.com/us/r1000/019/Music/b6/8c/c5/mzm.epegonxg.aac.p.m4a", "primaryGenreName":"Rock", "trackCount":12, "trackNumber":3, "trackTime":276042}]
}
You need then to decode these JSON data.
NSDictionary *jsonResultsParsed = [jsonResults JSONValue];
And finally get what you want :
NSDictionary *songDetailsDict = [[jsonResultsParsed objectForKey:#"results"] objectAtIndex:0];
If you want to determine user's country you will need to determine its country using its locale, here is the code I am using :
- (NSString *)getUserCountry
{
NSLocale *locale = [NSLocale currentLocale];
return [locale objectForKey: NSLocaleCountryCode];
}
Hope this helps.
Thierry
Edit: Finally a doc is available:
http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
This document for iTunes Store Web Service Search API (pdf), although old and incomplete, seems to be the way to accomplish this.
It's a painful experience setting this up though, as has been every other part of the affiliate programme.

iPhone: Beta Features of Facebook Connect

I have an iPhone app idea that will include viewing your news feed( stream ) in an iPhone app. There is a lot more to it than that, but I'm wondering why I can't find any apps on the app store that lets you view your stream in some way. Does anyone know why?
Does facebook frown on this? There is a API method stream.get that lets you do this but it's in beta. Is it a bad idea to use the beta methods in an app?
I'm just suprised that there is so many different twitter clients but there is just on facebook client and why hasn't created streams in an iPhone app besides the main facebook app?
I have implemented what you are talking about and my app is in the App Store, albeit only in a couple European stores currently. It was, however, reviewed and approved in the US App Store. I can't send a link for it currently as we are not yet announcing it in the US (until December), however, I assure you it can be done and is not too hard to implement.
I don't think Facebook frowns upon this so much as I think their API just hasn't matured enough yet. It's getting there, though. I think mostly what you see (or don't see in the App Store) is from a lack of vision for how to use Facebook for applications. The official Facebook app provides what users need but ideas like yours are going to grow as more and more people (developers/entrepreneurs) realize that Facebook is not just a social network, but an entire social networking platform they can leverage in a powerful way... Ok. I've said too much. Cool stuff is coming in December, though. ;-)
If you don't want to use the beta features, you can go for FQL to get what you want. Here is the code I used to implement pulling the last 20 friend status updates:
NSString* fql = [NSString stringWithFormat:
#"SELECT uid, pic_square, name, status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = %lld) AND status.time > 0 ORDER BY status.time DESC LIMIT 20", fbSession.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"query"];
last20FriendsStatusRequest = [FBRequest requestWithDelegate:self];
[last20FriendsStatusRequest call:#"facebook.fql.query" params:params];
And then the delegate callback looks like this:
- (void)request:(FBRequest*)request didLoad:(id)result
{
if (request == last20FriendsStatusRequest)
{
// Callback to my delegate here. result is an NSArray*
// of NSDictionaries* containing key-value pairs for the
// fields you requested in the query, e.g. uid, pic_square,
// name, and status. pic_square is the URL of the user's
// profile picture icon.
}
}
Let me know if you need any more info.
I guess people haven't found a use for it. Other developers may be afraid of the beta tag (yes Facebook, unlike Google, treats it as a beta tag -- it's subject to change and may break your app). It's up to your judgement if you think it's "safe" enough. We're currently developing a commercial iPhone application that uses stream.get.
On the desktop there are multiple apps that user Stream.get(), which could as well be done on iPhone