productsRequest response method is not calling

后端 未结 4 1921
孤街浪徒
孤街浪徒 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:51

    Try to implement also - (void)request:(SKRequest *)request didFailWithError:(NSError *)error method - may be there're some errors in processing of your requests.

    0 讨论(0)
  • 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:
    }
    
    0 讨论(0)
  • 2021-02-12 23:01

    I've had a similar problem (error: Cannot connect to iTunes Store). After upgrading iTunes Beta to the latest version it started working again.

    0 讨论(0)
  • 2021-02-12 23:13

    I had the same problem. I had created a helper class to handle the IAP and check for the products. What I finally found was the instance of the class I created was being released before the response came back, thus the delegate methods never got called because they did not exist anymore.

    I solved my problem by retaining the instance of the helper class in the class I called it from using @proprty(strong, nonatomic)...

    If you are not using a helper class and coding it into an existing class then the answer above will work by retaining your SKProductRequest.

    0 讨论(0)
提交回复
热议问题