productsRequest response method is not calling

后端 未结 4 1920
孤街浪徒
孤街浪徒 2021-02-12 22:30

I am implementing an in app purchase and I am sending the request to apple store through

- (void) requestProductData
{
 SKProductsRequest *request= [[SKProductsR         


        
4条回答
  •  温柔的废话
    2021-02-12 22:58

    I faced the same problem, but in my case the cause was that I was using Automatic Reference Counting and I forgot to retain the request.

    My code was like:

    - (void) requestProductData
    {
        SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:ProductIdentifier]];
        request.delegate = self;
        [request start];
    }
    

    But delegate's productsRequest:didReceiveResponse: never got called.

    A fix would be:

    @property (strong, nonatomic) SKProductsRequest *request;
    
    - (void) requestProductData
    {
        self.request= [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:ProductIdentifier]];
        self.request.delegate = self;
        [self.request start];
        // you can nil request property in request:didFailWithError: and requestDidFinish:
    }
    

提交回复
热议问题