Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

[MKStoreKit-notificationForStore] #234

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions MKStoreKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ extern NSString *const kMKStoreKitReceiptValidationFailedNotification;
*/
extern NSString *const kMKStoreKitSubscriptionExpiredNotification;

extern NSString *const kMKStoreKitSubscriptionTransactionCompletedNotification;

/*!
* @abstract This notification is posted when MKStoreKit completed subscribing to AppStore.
*/


/*!
* @abstract The singleton class that takes care of In App Purchasing
Expand Down
5 changes: 5 additions & 0 deletions MKStoreKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
NSString *const kMKStoreKitRestoringPurchasesFailedNotification = @"com.mugunthkumar.mkstorekit.failedrestoringpurchases";
NSString *const kMKStoreKitReceiptValidationFailedNotification = @"com.mugunthkumar.mkstorekit.failedvalidatingreceipts";
NSString *const kMKStoreKitSubscriptionExpiredNotification = @"com.mugunthkumar.mkstorekit.subscriptionexpired";
NSString *const kMKStoreKitSubscriptionTransactionCompletedNotification =
@"com.mugunthkumar.mkstorekit.subscriptionCompleted";

NSString *const kSandboxServer = @"https://sandbox.itunes.apple.com/verifyReceipt";
NSString *const kLiveServer = @"https://buy.itunes.apple.com/verifyReceipt";
Expand Down Expand Up @@ -222,6 +224,7 @@ - (void)restorePurchases {

- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error {
[[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitRestoringPurchasesFailedNotification object:error];
[[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitSubscriptionTransactionCompletedNotification object:error];
}

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
Expand Down Expand Up @@ -418,6 +421,8 @@ - (void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloa

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
transaction.transactionState != SKPaymentTransactionStatePurchasing ? [[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitSubscriptionTransactionCompletedNotification object:transaction] : nil;

switch (transaction.transactionState) {

case SKPaymentTransactionStatePurchasing:
Expand Down