If purchases are made through the Apple App Store (using the StoreKit infrastructure), you need to get the price + currency from the SKProduct object (prices will vary).
https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKProduct_Reference/
Update
- You need to complete a request to download available products.
var productID:NSSet = NSSet(object: "product_id_on_itunes_connect"); var productsRequest:SKProductsRequest = SKProductsRequest(productIdentifiers: productID); productsRequest.delegate = self; productsRequest.start();
- The delegate request will return SKProduct .
func productsRequest (request: SKProductsRequest, didReceiveResponse response: SKProductsResponse) { println("got the request from Apple") var validProducts = response.products if !validProducts.isEmpty { var validProduct: SKProduct = response.products[0] as SKProduct if (validProduct.productIdentifier == self.product_id) { println(validProduct.localizedTitle) println(validProduct.localizedDescription) println(validProduct.price) buyProduct(validProduct); } else { println(validProduct.productIdentifier) } } else { println("nothing") } }
- SKProduct contains all the necessary information to display the localized price, but I suggest creating the SKProduct category, which formats the price + currency for the current user locale
import StoreKit extension SKProduct { func localizedPrice() -> String { let formatter = NSNumberFormatter() formatter.numberStyle = .CurrencyStyle formatter.locale = self.priceLocale return formatter.stringFromNumber(self.price)! } }
Information obtained from here and here .
f3n1kc
source share