Reputation: 3658
I want my App to be used from few iTunes stores. I read NSLocale Class Reference and they are talking about "current user". So, who is "current user"? Is it user which has downloaded app?
1) is it possible to get NSLocale depending on current appleID country or iTunes store country from which my App was downloaded?
2) is it possible to simulate NSLocale to test my App?
Upvotes: 0
Views: 626
Reputation: 3658
Mates, i found a solution to get user's (Apple ID, iTunes store) locale! You can get locale from SKProduct.
if([SKPaymentQueue canMakePayments])
{
[self requestProductData];
}
#pragma mark -
#pragma mark In-App Purchase Delegate Methods
- (void)requestProductData
{
NSLog(@"IN-APP:requestProductData");
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:<your in-app identifier>]];
request.delegate = self;
[request start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *myProduct = [[NSArray alloc]initWithArray:response.products];
if ([myProduct count]>0)
{
SKProduct *product = [myProduct objectAtIndex:0];
NSLog(@"Price: %.2f",product.price.floatValue);
NSLog(@"Price Locale: %@",product.priceLocale.localeIdentifier);
NSLog(@"Product Identifier: %@",product.productIdentifier);
NSLog(@"IN-APP:array count: %i", [myProduct count]);
[request autorelease];
}
[myProduct release];
myProduct = nil;
}
Upvotes: 1
Reputation: 318774
In iOS, there is no such thing as a "current user". The reference to "current user" in the NSLocale
docs is probably a hold over from the OS X docs.
In iOS, run the Settings app and go to General, then International. The "Region Format" and the "Language" settings define what you get back in iOS for [NSLocale currentLocale]
.
There is no way, in iOS, for a third party app to obtain any sort of appleID or information about a specific iTunes store.
To directly answer your two questions:
1) No, you have no access to this information
2) Yes, run the Settings app and change the Language and/or Region Format settings. This will affect the NSLocale
you obtain in your app.
Upvotes: 1