diff --git a/MKStoreKit/MKStoreKit.h b/MKStoreKit/MKStoreKit.h index 4401bec..12c3615 100644 --- a/MKStoreKit/MKStoreKit.h +++ b/MKStoreKit/MKStoreKit.h @@ -65,6 +65,12 @@ */ extern NSString *const kMKStoreKitProductsAvailableNotification; + +/*! + * @abstract This notification is posted when if MKStoreKit finds invalid product ids after initialization sequence + */ +extern NSString *const kMKStoreKitProductsInvalidIdsNotification; + /*! * @abstract This notification is posted when MKStoreKit completes purchase of a product */ diff --git a/MKStoreKit/MKStoreKit.m b/MKStoreKit/MKStoreKit.m index c4c678d..e025250 100644 --- a/MKStoreKit/MKStoreKit.m +++ b/MKStoreKit/MKStoreKit.m @@ -40,6 +40,7 @@ @import StoreKit; NSString *const kMKStoreKitProductsAvailableNotification = @"com.mugunthkumar.mkstorekit.productsavailable"; +NSString *const kMKStoreKitProductsInvalidIdsNotification = @"com.mugunthkumar.mkstorekit.productsinvalidids"; NSString *const kMKStoreKitProductPurchasedNotification = @"com.mugunthkumar.mkstorekit.productspurchased"; NSString *const kMKStoreKitProductPurchaseFailedNotification = @"com.mugunthkumar.mkstorekit.productspurchasefailed"; NSString *const kMKStoreKitProductPurchaseDeferredNotification = @"com.mugunthkumar.mkstorekit.productspurchasedeferred"; @@ -135,7 +136,7 @@ - (void)restorePurchaseRecord { if (self.purchaseRecord == nil) { self.purchaseRecord = [NSMutableDictionary dictionary]; } - NSLog(@"%@", self.purchaseRecord); +// NSLog(@"[MKStoreKit] self.purchaseRecord: %@", self.purchaseRecord); } - (void)savePurchaseRecord { @@ -148,10 +149,10 @@ - (void)savePurchaseRecord { #endif if (!success) { - NSLog(@"Failed to remember data record"); + NSLog(@"[MKStoreKit] Failed to remember data record"); } - NSLog(@"%@", self.purchaseRecord); +// NSLog(@"[MKStoreKit] self.purchaseRecord: %@", self.purchaseRecord); } #pragma mark - @@ -214,7 +215,8 @@ - (void)startProductRequest { - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { if (response.invalidProductIdentifiers.count > 0) { - NSLog(@"Invalid Product IDs: %@", response.invalidProductIdentifiers); + [[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitProductsInvalidIdsNotification + object:response.invalidProductIdentifiers]; } self.availableProducts = response.products; @@ -223,7 +225,7 @@ - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProdu } - (void)request:(SKRequest *)request didFailWithError:(NSError *)error { - NSLog(@"Product request failed with error: %@", error); + NSLog(@"[MKStoreKit] Product request failed with error: %@", error); } #pragma mark - @@ -248,7 +250,7 @@ - (void)initiatePaymentRequestForProductWithIdentifier:(NSString *)productId { if (!self.availableProducts) { // TODO: FIX ME // Initializer might be running or internet might not be available - NSLog(@"No products are available. Did you initialize MKStoreKit by calling [[MKStoreKit sharedKit] startProductRequest]?"); + NSLog(@"[MKStoreKit] No products are available. Did you initialize MKStoreKit by calling [[MKStoreKit sharedKit] startProductRequest]?"); } if (![SKPaymentQueue canMakePayments]) { @@ -290,10 +292,10 @@ - (void)requestDidFinish:(SKRequest *)request { if([request isKindOfClass:[SKReceiptRefreshRequest class]]) { NSURL *receiptUrl = [[NSBundle mainBundle] appStoreReceiptURL]; if ([[NSFileManager defaultManager] fileExistsAtPath:[receiptUrl path]]) { - NSLog(@"App receipt exists. Preparing to validate and update local stores."); + NSLog(@"[MKStoreKit] App receipt exists. Preparing to validate and update local stores."); [self startValidatingReceiptsAndUpdateLocalStore]; } else { - NSLog(@"Receipt request completed but there is no receipt. The user may have refused to login, or the reciept is missing."); + NSLog(@"[MKStoreKit] Receipt request completed but there is no receipt. The user may have refused to login, or the reciept is missing."); // Disable features of your app, but do not terminate the app } } @@ -312,7 +314,7 @@ - (void)startValidatingAppStoreReceiptWithCompletionHandler:(void (^)(NSArray *r NSData *receiptData = [NSData dataWithContentsOfURL:receiptURL]; if (!receiptData) { // Validation fails - NSLog(@"Receipt exists but there is no data available. Try refreshing the reciept payload and then checking again."); + NSLog(@"[MKStoreKit] Receipt exists but there is no data available. Try refreshing the reciept payload and then checking again."); completionHandler(nil, nil); return; } @@ -387,7 +389,7 @@ - (BOOL)purchasedAppBeforeVersion:(NSString *)requiredVersion { - (void)startValidatingReceiptsAndUpdateLocalStore { [self startValidatingAppStoreReceiptWithCompletionHandler:^(NSArray *receipts, NSError *error) { if (error) { - NSLog(@"Receipt validation failed with error: %@", error); + NSLog(@"[MKStoreKit] Receipt validation failed with error: %@", error); [[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitReceiptValidationFailedNotification object:error]; } else { __block BOOL purchaseRecordDirty = NO; @@ -517,14 +519,14 @@ - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)tran } - (void)failedTransaction:(SKPaymentTransaction *)transaction inQueue:(SKPaymentQueue *)queue { - NSLog(@"Transaction Failed with error: %@", transaction.error); + NSLog(@"[MKStoreKit] Transaction Failed with error: %@", transaction.error); [queue finishTransaction:transaction]; [[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitProductPurchaseFailedNotification object:transaction.payment.productIdentifier]; } - (void)deferredTransaction:(SKPaymentTransaction *)transaction inQueue:(SKPaymentQueue *)queue { - NSLog(@"Transaction Deferred: %@", transaction); + NSLog(@"[MKStoreKit] Transaction Deferred: %@", transaction); [[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitProductPurchaseDeferredNotification object:transaction.payment.productIdentifier]; }