How to access the price of a product in SKPayment?

前端 未结 5 1669
無奈伤痛
無奈伤痛 2020-12-23 02:41

I am having an In-App-Purchase for an iPhone app.

I want to display the price in the users local currency in a UILabel. For this I need the price & currency in a

5条回答
  •  渐次进展
    2020-12-23 03:13

    The correct way to determine any of that information is to use an SKProduct object, retrieved from the SKProductResponse object returned to the delegate after a call to - (void) start on an initialized SKProductsRequest. Something like this:

    SKProductsRequest *req = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"Identifier"]];
    req.delegate = self;
    [req start];
    
    - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse: (SKProductsResponse *)response {
        [request autorelease];
        if (response.products.count) {
            SKProduct *product = [response.products objectAtIndex:0];
            NSLocale *priceLocale = product.priceLocale;
            NSDecimalNumber *price = product.price;
            NSString *description = product.localizedDescription;
        }
    }
    

提交回复
热议问题