SKProductsRequestDelegate有一个方法:
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
Run Code Online (Sandbox Code Playgroud)
通常,我发现这些类型的代表将有几种处理多个案例的方法,而不仅仅是成功.例如:
-(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *) error
Run Code Online (Sandbox Code Playgroud)
如何检查此代码是否因某些原因失败,例如.用户离线了吗?
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] ... ];
productsRequest.delegate = self;
[productsRequest start];
Run Code Online (Sandbox Code Playgroud) 哇,最后XCode 4.2/iOS5模拟器有StoreKit支持.
在我的应用程序中,我注意到当StoreKit要求AppleID /密码时,我可以使用模拟器屏幕键盘输入该信息,但不能通过Mac键盘输入.
这是正常的还是我还有其他问题?
在我的应用程序中,我使用SKStoreProductViewController显示更多应用程序,但Apple商店审核小组拒绝它的原因如下:
"点击更多应用按钮时会显示错误消息."
当我在我的设备上测试时,一切正常.
以下是Apple发给我的截图,可能是什么问题?

示例代码:
__weak typeof(self) weakSelf = self;
SKStoreProductViewController* vc = [[SKStoreProductViewController alloc] init];
vc.delegate = self;
[vc loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @1000000000} completionBlock:^(BOOL result, NSError * _Nullable error) {
if(result==NO){
//handle failure
return;
}
[weakSelf presentViewController:vc animated:YES completion:nil];
}];
Run Code Online (Sandbox Code Playgroud) 我正在应用购买中实现恢复.我有一个按钮,其动作是
@IBAction func restorePurchases(send : AnyObject){
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
// if (success) {
// I want to do something here
// }
}
Run Code Online (Sandbox Code Playgroud)
我的问题是.
尝试使用其中一个StoreKit常量时,我收到错误"使用未解析的标识符":
SKErrorClientInvalid
SKErrorPaymentCancelled
SKErrorPaymentInvalid
SKErrorPaymentNotAllowed
SKErrorStoreProductNotAvailable
SKErrorUnknown
Run Code Online (Sandbox Code Playgroud)
您的代码可能如下所示:
if transaction.error!.code == SKErrorPaymentCancelled {
print("Transaction Cancelled: \(transaction.error!.localizedDescription)")
}
Run Code Online (Sandbox Code Playgroud)
改变了什么?我需要导入一个新模块吗?
在iOS模拟器中购买是众所周知的"不,这是不可能的".但是,SKProduct通过向SKProductsRequestiOS 11之前的工作提供产品标识来检索信息.
在SKProductsRequestDelegate我收到以下错误:Error Domain=SSErrorDomain Code=0 "Cannot connect to iTunes Store"
从我发现,这可能发生在产品标识符错误或Apple Sandbox服务器关闭时.然而事实并非如此,因为产品在iOS 10上运行良好.
我对产品提取的实现与Apple指南中的实现几乎相同
是否有其他人遇到此问题或找到解决方案?
当应用程序在物理设备上运行时,产品正在正常加载.我正在使用Xcode 9.0.
我有一个应用程序,我最近更新,以便在应用程序购买中使用.之前的版本(付费但没有在应用内购买)是1.0,当前版本是1.1.
由于应用程序内购买实际上解锁了所有功能(包含在付费版本1.0中),我想要一种方式,如果用户按下我的恢复购买按钮,则最初下载的版本1.0将被升级.
为此,我首先尝试恢复购买,如果回复:
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
Run Code Online (Sandbox Code Playgroud)
如果这为我提供了一个事务计数为0的队列,我检查收据以查看安装的原始版本是否为1.0.
获得收据的代码是根据Apple的文档
- (void)tryRestoreFromOriginalPurchase
{
// Load the receipt from the app bundle
NSError *error;
NSData *receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
if (receipt == nil) {
[self restoreFromOriginalVersionWithReceipt:nil];
return;
}
// Create the JSON object that describes the request
NSDictionary *requestContents = @{@"receipt-data": [receipt base64EncodedStringWithOptions:0]};
NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents options:0 error:&error];
if (!requestData) {
[self restoreFromOriginalVersionWithReceipt:nil];
return;
}
// Create a POST request with the receipt data
NSURL *storeURL = [NSURL URLWithString:@"https://buy.itunes.apple.com/verifyReceipt"]; …Run Code Online (Sandbox Code Playgroud) 当我SKProductsRequest从 Xcode 12 GM 中的 UI 测试会话运行时,它总是失败并显示以下错误:
Error Domain=SKErrorDomain Code=0 "UNKNOWN_ERROR" UserInfo={NSLocalizedDescription=UNKNOWN_ERROR, NSUnderlyingError=0x600003d30f30 {Error Domain=ASDErrorDomain Code=507 "Error decoding object" UserInfo={NSLocalizedDescription=Error decoding object, NSLocalizedFailureReason=Attempted to decode store response}}}
Run Code Online (Sandbox Code Playgroud)
我尝试使用SKTestSession有效的.storekit配置文件,但没有帮助。虽然在我的单元测试中这适用于SKTestSession.
有没有办法在 Xcode 12 GM 的 UI 测试中测试存储?还是SKTestSession只能在单元测试中使用?
我正在尝试将应用程序从原始 StoreKit API 升级到 StoreKit 2。该应用程序当前正在下载 Apple 托管的内容。SKPaymentTransaction.downloads 是用于获取此内容的 SKDownload 类型的数组。我在 StoreKit 2 Transaction 结构中没有看到类似的变量。当您使用 StoreKit 2 进行购买时,如何获取 Apple 托管内容的下载信息?