问题描述
我的应用中会弹出一个自定义提醒视图,询问用户是否愿意购买我的应用内购买项目.在警报视图中,我还列出了从与其关联的 SKProduct 派生的应用内购买的价格.
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?).
每次显示对话时,是否需要查询Apple重新加载产品数据?听起来真的很没效率...
Each time I display the dialogue, do I need to query Apple to reload the products data? That sounds really inefficient...
碰巧,如果您更新了应用内购买之一的价格,SKProductsRequestDelegate 是否会收到提醒,以便它自动更新您的产品?
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?
推荐答案
似乎解决这种情况的最佳方法是在应用启动时加载产品,并在应用每次激活时重新加载产品.在应用委托中实现以下方法可以解决这个问题:
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];
}
这篇关于更新应用内购买的价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!