ios积累留着看

消耗型和非自动订阅型苹果内购(IAP)优化

2017-07-02  本文已影响249人  iDeveloper

最近项目内购,每天有用户反馈无法进行内购或者付款成功后商品未到账的情况,于是进行了分析优化.


分析

 SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers];
productsRequest.delegate = delegate;
 [productsRequest start];

该问题苹果服务器原因,无解中.(T_T)
但是我们可以曲线救国使用废弃api创建SKPayment进行购买.(亲测可用)

+ (id)paymentWithProductIdentifier:(NSString *)identifier NS_DEPRECATED_IOS(3_0, 5_0, "Use +paymentWithProduct: after fetching the available products using SKProductsRequest");
1 . 苹果扣款成功回调后,因为我们服务器或者网络原因等导致二次验证失败.
2 . 苹果扣款成功后,没有进行正确回调.

曾经苹果服务器有两天抽风,导致我们IAP全部失败,奇怪的是别人的虽然也回调失败,但是还是能成功购买.

优化

针对第一种可能:

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

后续再进行二次验证成功后在finishTransaction.

// Only valid if state is SKPaymentTransactionStatePurchased.
@property(nonatomic, readonly, nullable) NSData *transactionReceipt NS_DEPRECATED_IOS(3_0, 7_0, "Use -[NSBundle appStoreReceiptURL]");

iOS7新方法获取的transactionReceipt在多次进行内购后,会变大,甚至达几百KB.
iOS6老方法获取则小很多,只有几KB.
先尝试用iOS6的transactionReceipt进行验证,失败后再用iOS7的transactionReceipt进行验证,以提高二次验证的成功率.

针对第二种可能:

其他优化:

An opaque identifier for the user’s account on your system.
This is used to help the store detect irregular activity. For example, in a game, it would be unusual for dozens of different iTunes Store accounts making purchases on behalf of the same in-game character.
The recommended implementation is to use a one-way hash of the user’s account name to calculate the value for this property.

上线后,再来更新优化后的效果... C U around.

上一篇 下一篇

猜你喜欢

热点阅读