SKStoreProductViewController loadProductWithParameters not working on iOS version 8.4

1.8k views Asked by At

I am using bellow code to review my app. But its not working on iOS version 8.4 Its working fine for iOS version 8.3.

    if ([SKStoreProductViewController class] != nil) {
    SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
    [storeViewController setDelegate:self];

    NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
    f.numberStyle = NSNumberFormatterDecimalStyle;
    NSNumber *myNumber = [f numberFromString:kAppleID];

    NSDictionary *productParams = @{ SKStoreProductParameterITunesItemIdentifier : myNumber };
    [storeViewController loadProductWithParameters:productParams completionBlock:^(BOOL result, NSError *error) {
        if (result == YES) {
            [self presentViewController:storeViewController animated:YES completion:nil];
        } else {
            // handle the error
            NSLog(@"%@",error.description);
        }
    }];
}

Please help me to fix this , and also let me know why its not working? Thanks A Lot

1

There are 1 answers

2
Rohit Wankhede On

Sorry, small mistake i did at code. storeViewController loadProductWithParameters: block will return NO if its not loaded. It means you are ready to present storeViewController. So i place changed the condition and it fixed my problem

if ([SKStoreProductViewController class] != nil) {
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
[storeViewController setDelegate:self];

NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
f.numberStyle = NSNumberFormatterDecimalStyle;
NSNumber *myNumber = [f numberFromString:kAppleID];

NSDictionary *productParams = @{ SKStoreProductParameterITunesItemIdentifier : myNumber };
[storeViewController loadProductWithParameters:productParams completionBlock:^(BOOL result, NSError *error) {
    if (error) {
         // handle the error
        NSLog(@"%@",error.description);
    } else {
        [self presentViewController:storeViewController animated:YES completion:nil];            
    }
}];

}