应用内购买未调用的SKProductRequest代理

时间:2014-01-21 10:46:44

标签: ios objective-c in-app-purchase skproduct

我知道这个问题被问了很多次。我看了很多,但我无法解决这个问题。

我添加了Storekit framework并创建了类型为NSObject的InAppPurchaseManager类。

我正在制作一个我需要提出产品请求的实例。

InAppPurchaseManager *inApp = [[InAppPurchaseManager alloc] init];
[inApp loadStore:@"TestProduct"];

我创建了一个SKProductsRequest的类属性。

@property (retain, nonatomic) SKProductsRequest *productsRequest;

// loadStore方法

- (void)loadStore:(NSString *)_productID
{
    productID = _productID;
    // restarts any purchases if they were interrupted last time the app was open
    [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];   
    // get the product description (defined in early sections)
    [self requestProUpgradeProductData];
}

- (void)requestProUpgradeProductData 
{

    NSSet *productIdentifiers = [NSSet setWithObject:productID];
    self.productsRequest = [[SKProductsRequest alloc]     
        initWithProductIdentifiers:productIdentifiers];
    self.productsRequest.delegate = self;
    [self.productsRequest start];
}

//代表

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:                               
      (SKProductsResponse *)response
{
    //never being called    
}

- (void)requestDidFinish:(SKRequest *)request 
{
    //never being called
}

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error 
{
    //never being called
}

我的界面看起来像这样

@interface InAppPurchaseManager : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver, SKRequestDelegate>

请建议我该如何解决这个问题。

编辑:这个

[self.productsRequest start];

执行它来自

-(void) dealloc {

}

1 个答案:

答案 0 :(得分:-3)

通过制作InAppPurchaseManager的属性来解决此问题。