問題
自從iOS12開始自阱,部分(好吧就是我們的)App一直內購失敗技掏,商品獲取能成功澄暮,就是addPayment
后總提示cannot connect to itunes store
{
NSErrorFailingURLKey = https://sandbox.itunes.apple.com/bag.xml?ix=6&os=11&locale=zh_CN;
NSErrorFailingURLStringKey = "https://sandbox.itunes.apple.com/bag.xml?ix=6&os=11&locale=zh_CN";
NSLocalizedDescription = "無法連接到 iTunes Store";
NSUnderlyingError = Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4};
_kCFStreamErrorCodeKey = -2102;
_kCFStreamErrorDomainKey = 4;
}
直接放上答案:
SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
payment.quantity = 1;
payment.requestData = requestData;
// ...
這里的requestData
是不能賦值的蝌以,官方文檔說明如下:
Discussion
The default value is nil. If requestData is not nil, your payment will be rejected by the Apple App Store.
在iOS12之前糊啡,雖然是不允許的柱彻,但是蘋果卻沒做什么限制豪娜,RELEASE環(huán)境也沒問題。iOS12突然這樣了哟楷,真是讓人措手不及瘤载。
總結兩點:
- 認真讀文檔
- 蘋果爸爸不讓干的事兒,能不干就別干