Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile error in MKStoreKit

I'm getting an error:

Incompatible block pointer types sending 'void (^)(NSString *_strong)' to parameter of type 'void (^)(NSString *_strong, NSData *__strong)'

When I'm implementing MKStoreKit 4.3 in my app on the line of onComplete:

-(IBAction)purchaseFull {
    [[MKStoreManager sharedManager] buyFeature:@"productID"
                                onComplete:^(NSString* purchasedFeature)
    {
         NSLog(@"Purchased: %@", purchasedFeature);
         //purchaseBtn.hidden = YES;
    }
    onCancelled:^
    {
        NSLog(@"User Cancelled Transaction");
    }];
}
like image 356
XIII Avatar asked Jun 21 '26 03:06

XIII


1 Answers

The API you are trying to use has a method like this:

// use this method to invoke a purchase
- (void) buyFeature: (NSString*) featureId         
         onComplete: (void (^)(NSString* purchasedFeature, 
                               NSData* purchasedReceipt)) completionBlock
        onCancelled: (void (^)(void)) cancelBlock;

but, for the completionBlock parameter, you're passing

^(NSString* purchasedFeature) {
      NSLog(@"Purchased: %@", purchasedFeature);             
      //purchaseBtn.hidden = YES;        
}

which means you are missing the second (NSData*) parameter.

Change your code to something like this:

^(NSString* purchasedFeature, NSData* purchasedReceipt) {
      NSLog(@"Purchased: %@", purchasedFeature);             
      //purchaseBtn.hidden = YES;        
}
like image 180
Nate Avatar answered Jun 23 '26 16:06

Nate



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!