简体   繁体   English

应用内购买适用于iOS 3&5,但不适用于iOS 4

[英]In-App purchase works on iOS 3&5 but not on iOS 4

I have a problem I cannot solve and I'm stuck. 我有一个无法解决的问题,被困住了。

I've implemented an in-App purchase screen, The problem is that when I'm checking that on iOS3.1.3 it works perfectly also on iOS5 simulator, but when using iOS4 I dont get and products on the response, 我已经实现了一个应用内购买屏幕,问题是,当我在iOS3.1.3上进行检查时,它也可以在iOS5模拟器上完美运行,但是在使用iOS4时,我没有得到响应,并且产品也没有,

The relevant code I'm using: 我正在使用的相关代码:

-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
if ([response.products count]==0) {

       // Always gets in here on iOS4....

}else{

   //get here on 3.1.3 or 5

    [productDetailsList addObjectsFromArray: response.products];
}

....

[request release];  
}

- (void)requestProductData {
for (short item_count = 1; item_count <=4 ; item_count++) {
    [productIdentifierList addObject:[NSString stringWithFormat:@"myApp.item.%d", item_count]];


}

SKProductsRequest *request = [[[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:productIdentifierList]] retain];

request.delegate = self;
[request start];
}

the .h file looks like this: .h文件如下所示:

#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>

@interface viewController : UIViewController
<SKProductsRequestDelegate, SKPaymentTransactionObserver> {

NSMutableArray *productIdentifierList;
NSMutableArray *productDetailsList;
NSMutableArray *transactionHistory;

}
@property (nonatomic, retain) NSMutableArray *productIdentifierList;
@property (nonatomic, retain) NSMutableArray *productDetailsList;
@property (nonatomic, retain) NSMutableArray *transactionHistory;

- (void)requestProductData;
- (void)completeTransaction: (SKPaymentTransaction *)transaction;
- (void)restoreTransaction: (SKPaymentTransaction *)transaction;
- (void)failedTransaction: (SKPaymentTransaction *)transaction;
- (void)recordTransaction: (SKPaymentTransaction *)transaction;
- (void)provideContent: (NSString *)productIdentifier;
@end

I've tried to make all provision from scratch and that didn't resolve the problem, Maybe that's something related to memory management but I cannot figure out what. 我试图从头开始做所有准备工作,但是并不能解决问题,也许这与内存管理有关,但是我不知道要做什么。

Weird it works on my 3.1.3 and not on 4.2.1. 很奇怪,它只适用于我的3.1.3,而不适用于4.2.1。

Please help... 请帮忙...

StoreKit API works on Device only in 4.2, so you must try to execute it in Device. StoreKit API仅在4.2中可在Device上使用,因此您必须尝试在Device中执行它。 while in 3.1 ios simulator version i not worked but in ios5 Simulator it is working i think it may be the bug of ios5 Simulator or they are trying to give new functionality. 虽然在3.1 ios模拟器版本中我无法正常工作,但在ios5模拟器中却可以正常工作,我认为这可能是ios5模拟器的错误,或者他们正在尝试提供新功能。 But in Apple's site they have mention that storekit will works only on Device. 但是在Apple网站上,他们提到storekit仅在Device上可用。

So you just try the same b building your project on device. 因此,您只需尝试在设备上构建项目即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM