I am fetching the in app purchase items for my app from my web server.the web-server gives the product title, description and price...
Currently i am displaying the each product using the product title,description and price.Currently i am showing the currency in $.
Now i am having the doubt that , can i display the prices as such?when i referred some URL, it seems that prices needs to be localized.
So do i need to display the prices localized which is fetched from my-server? please let me know how should i proceed?
Thanks a lot for stopping by..
Yes, you should show localized prices.
From App Store Quick Reference: Getting Started with In-App Purchase on iOS and OS X Lion:
Since your application may be available in App Stores with a region specific currency and
language, your item’s localized description and pricing information should be pulled from the
App Store via StoreKit’s products request API. You’ll use the information returned from the
products request to populate the user interface you present to the customer for item selection
and purchase
The product request API from StoreKit is pretty straightforward, it returns a ProductResponse, which contains an SKProduct, which includes both the price and the priceLocale. Per the SKProduct Class Reference, your code to format the price in the current local should be something like:
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:product.priceLocale];
NSString *formattedString = [numberFormatter stringFromNumber:product.price];
Related
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.
I am first time implementing the inapp purchase and right now i am inserting product id static in my app and through that i am retrieved product but is there any way to do this dynamically?
I am following ray wenderlich tutorial for inapp purchase.
and hare is my code.
NSSet *productIdentifiers = [NSSet setWithObjects:
#"my Product id",
#"my Product id",
#"my Product id",
#"my Product id",
#"my Product id",
nil];
EDIT:-
I am also not getting products. and I checked that all identifier i entered is correct.and bundle identifier for product plus provisioning is also correct. I also submitted binary to iTunes connect to test binary but still didn't get success!
Thanx in advance for any help.
I have a task to develop the application related to address and access the birthdate from it. And if the user has to exists in the address then i can enter it manually from my application to address book.
I have to develop the application related to address book. From address book i have to get name,phone no,email, and birthday. so i can easily get it on my application. But for get i have set all thing from address book. But i also have to give facility to add the contact detail as above given field. and i can not find easily that how to add birthday in address book i have search a lot but i cant found it,
So,please help me and provide some sample code for it.
int recordId=123 //recordId in address book for record we want to update
//save birthday to address book
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef person = ABAddressBookGetPersonWithRecordID (addressBook,recordId);
CFErrorRef error = NULL;
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:#"dd.MM.yyyy"];
//don't set year in address book (yyyy=1604)
NSDate *date = [formatter dateFromString:[NSString stringWithFormat:#"%#.1604",#"29.03"]];
[formatter release];
ABRecordSetValue(person, kABPersonBirthdayProperty,(CFDateRef)date, &error);
ABAddressBookSave (addressBook,&error);
CFRelease(addressBook);
Don't forget to import AddressBook/AddressBook.h file and add AddressBook.framework.
There is a demo app in Apple's code library called QuickContacts. You can download it and refer it. In that demo app there is a functionality where in you can create a new contact and it will save that contact in your iPhone's contacts.
Now, you can modify that controller and customize it as per your requirements. I didn't go down into the tiniest detail but I guess this would help you. You can download that demo app called QuickContacts from here.
You might have to work a little bit but I hope it helps!
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.
As per the subject - is there an API to get the MCC/MNC on iPhone OS 2.1 or above?
Added in iOS4
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netInfo subscriberCellularProvider];
NSString *mcc = [carrier mobileCountryCode];
NSString *mnc = [carrier mobileNetworkCode];
http://developer.apple.com/library/ios/#Documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html
No, mobile network information is not available through the API. If you're looking for a unique device ID, take a look at UIDevice's uniqueIdentifer method; if you're looking for the country the device is in, you need Location Services; if you want a good indication of the user's home region, take a look at NSLocale; for anything else, just ask the user.
I think you could just get the phone number of the iPhone and parse it out for the country code.