Reputation: 31
I have a free App (already available in the App Store) that has a non-consumable IAP option that it's just a like a Premium Version with more functionalities...minimum deployment target is 8.0
I use the RMStore library (https://github.com/robotmedia/RMStore) for receipt validation... I realized that the validation is not correct when executing on a device that already made a purchase of any other App. I mean, if someone in his device (with his corresponding Apple ID) already made a purchase of any other App in the past, when entering in my App the receipt validation returns OK (like that person already purchased my Premium Version too) but it is not :-(
Herewith below is my code for receipt validation using RMStore (in the AppDelegate):
RMStoreAppReceiptVerifier *_receiptVerifier = [[RMStoreAppReceiptVerifier alloc] init];
[RMStore defaultStore].receiptVerifier = _receiptVerifier;
if (_receiptVerifier.verifyAppReceipt) {
NSLog(@"PREMIUM VERSION");
PremiumRM = YES;
} else {
NSLog(@"NOT PREMIUM VERSION");
PremiumRM = NO;
}
What is wrong?
By the way, in other posts of RMStore library and receipt validation here at StackOverFlow, "RMStoreAppReceiptVerificator" library is mentioned but I do not have it... do I need it as a mandatory? (I use "RMAppReceipt" and "RMStoreAppReceiptVerifier" libraries instead).
Upvotes: 0
Views: 537
Reputation: 31
I changed the code as follows...
- (BOOL)verifyReceiptWithCustomLogic
{
RMStoreAppReceiptVerifier *verificator = [RMStoreAppReceiptVerifier new];
if ([verificator verifyAppReceipt])
{
return [[RMAppReceipt bundleReceipt] containsInAppPurchaseOfProductIdentifier:_PremiumIdentifier];
}
return NO;
}
-(void)PremiumVerification
{
const BOOL verified = [self verifyReceiptWithCustomLogic];
if (verified)
{
// Verification succeeded
NSLog(@"PREMIUM VERSION");
_Premium = YES;
}
else
{ // Apple recommends to refresh the receipt if validation fails on iOS
[[RMStore defaultStore] refreshReceiptOnSuccess:^{
const BOOL verifiedagain = [self verifyReceiptWithCustomLogic];
if (verifiedagain)
{
// Verification succeeded
NSLog(@"PREMIUM VERSION");
_Premium = YES;
}
else
{
// Verification failed
NSLog(@"RECEIPT NOT VALID");
_Premium = NO;
}
} failure:^(NSError *error) {
// Verification failed
NSLog(@"RECEIPT NOT VALID");
_Premium = NO;
}];
}
}
PremiumVerification is called in application didFinishLaunchingWithOptions
of AppDelegate, and now it seems is working OK.
But on the other hand, in my opinion PremiumVerification should be called also in applicationDidBecomeActive
just to verify again the receipt when comes from the background or inactive state, is that correct?
Upvotes: 0