I have a problem. SKProductsRequest delegate methods are never getting called. this was previously asked but it had no answers. StoreKit delegate functions are not getting called
I'm not native english speaker, I may sound funny at times :P :(
I want to implement StoreKit in my iOS app. I made a class to handle all the StoreKit communication. This is the code:
@implementation VRStoreController
- (void) requestProducts
{
SKProductsRequest *request= [[SKProductsRequest alloc]
initWithProductIdentifiers:
[NSSet setWithObject: @"myProductID"]];
request.delegate = self;
[request start];
[[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:YES];
}
- (void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSLog(@"F7U12");
[[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
NSArray *myProducts = response.products;
NSLog(@"%@", myProducts);
}
I created an instance in my app delegate
@interface VRAppDelegate
@property (strong, nonatomic) VRStoreController *store;
@end
Strangely, this code works ok when I run [store requestProducts] in my appDidFinishLaunching: method.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//app initialization...
self.store = [[VRStoreController alloc]init];
[store requestProducts]; //This works ok, delegate method gets called.
return YES;
}
But when I run the code in settings tableView:didSelectRowAtIndexPath: the delegate method never gets called.
//VRAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//app initialization...
self.store = [[VRStoreController alloc]init];//initialize store
return YES;
}
//VRSettingsViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
//case 0, 1...
case 2:
{
VRStoreController *store = ((VRAppDelegate *)[UIApplication sharedApplication].delegate).store;
[store requestProducts]; //calls SKProductRequest start, but never calls delegate method.
NSLog(@"GO PRO");
}
default:
break;
}
}
I don't know what am I doing bad. Tried almost everything and no errors, no crashes, but the delegate never gets called. Any help would be very appreciated.
Thanks so much in advance!