Updating price of in app purchase

2019-06-01 06:10发布

I have a custom alert view that pops up in my app asking the user if they'd like to purchase one of my in app purchases. In the alert view, I also list the price of the in app purchase which I derive from the SKProduct associated with it.

The thing is, now I want to change the price of my in app purchase, but I'm collecting the product data when the app launches in the app delegate, so how should I go about this? (does the app delegate only launch when the first time the user launches the app?).

Each time I display the dialogue, do I need to query Apple to reload the products data? That sounds really inefficient...

By chance, if you update the price of one of your in app purchases, will the SKProductsRequestDelegate be alerted so it will update your products automatically?

Does anyone have a good solution to this situation?

1条回答
SAY GOODBYE
2楼-- · 2019-06-01 06:25

Seems the best way to remedy this situation is to load the products when the app launches and reload the products every time the app becomes active. Implementing the following method in the app delegate takes care of the problem:

- (void) applicationWillEnterForeground:(UIApplication *)application
{
    [self loadProducts];
}

- (void) loadProducts
{
    self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObjects: MyProduct1, MyProduct2 nil]];
    self.productsRequest.delegate = self;
    [self.productsRequest start];
}
查看更多
登录 后发表回答