I added IAP function in - (NSInteger)numberOfPagesInInfiniteScrollView:(GBInfiniteScrollView *)infiniteScrollView
, like below
- (GBInfiniteScrollViewPage *)infiniteScrollView:(GBInfiniteScrollView *)infiniteScrollView pageAtIndex:(NSUInteger)index;
{
. . . . . . Original Demo Code Omitted. . . . . .
// added for IAP
if (index == 0) {
SKProduct * product = (SKProduct *) [_products objectAtIndex:0];
BOOL productPurchased = [[SSIAPHelper sharedInstance] productPurchased:product.productIdentifier];
if (productPurchased) {
NSLog(@"BOOL is %hhd", productPurchased);
} else
NSLog(@"BOOL is %hhd ", productPurchased);
if (productPurchased) {
UIAlertView * purchasedAlert = [[UIAlertView alloc] initWithTitle:@"Purchased"
message:nil delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
purchasedAlert.tag = 100;
[purchasedAlert show];
} else {
UIAlertView * notPurchasedAlert = [[UIAlertView alloc] initWithTitle:@"NOT Purchased"
message:nil delegate:self
cancelButtonTitle:@"Buy"
otherButtonTitles:@"Cancel", nil];
notPurchasedAlert.tag = 200;
[notPurchasedAlert show];
}
}
}
Run the demo the first time, definitely, will show NOT Purchased alert view to remind purchase, then buy it. Then sliding to left direction or right and then sliding back to page index == 0, will show Purchased alert view. So, IAP is implemented correctly.
After pressing iPhone Home key, and killing the demo process, then run the demo again, page index == 0 is going to be presented. But, NOT Purchased alert view is also popping out. Putting NSLog
there shows productPurchased:product.productIdentifier
not get successfully.
The second thing is, tap the Cancel, then sliding to left or right direction, and then sliding back to index == 0
, it's popping out the Purchased alert view!
Oops, looks product.productIdentifier
can't be retrieved when showing page at index is 0! Do you know why it is? How to fix this?
Appreicated a lot in advance!