MKStoreKit started off in a pet project a couple of years ago and I wrote the first version in 2009.
Since then, it has seen tremendous adoption rates that, it has been the “go-to” framework for implementing In-App purchases in any iOS app today.

On iOS 4.3, Apple added a new type of subscription framework called, auto-renewable subscriptions.

Today, I’m adding this support to MKStoreKit along with several new features. If you have been following me on Twitter (@mugunthkumar) or on Github, you would have gotten the code a week ago.
Now that, I’m done with my testing it’s finally ready for some real-world adoption in your projects.

What’s New

  1. The main feature includes support for Auto-renewable subscriptions.
  2. The second important change is to move configuration related changes to a separate file,
    MKStoreKitConfigs.h and
    MKStoreKitConfigs.plist

    The plist contains a list of products you support and MKStoreKit automatically reads this and creates StoreKit requests on your behalf. This feature was partly inspired by a issue raised here by a contributor, dfabulich. But I didn’t like adding a datasource to MKStoreKit for various reasons. I think this method is cleaner than that. MKStoreKit now behaves like a standalone drop-in package.

  3. MKStoreKitDelegate removed in favour of Blocks
  4. Keychain support using SFHFKeychainUtils

    How to use

    The most important change to MKStoreKit is the use of a plist file instead of Macro strings for your product ids.
    The following screenshot shows the plist file organization.
    MKStoreKitConfigs.plist
    There are three main sections, Consumables, Non-consumables and Subscriptions. You specify your product inside each category based on how you added them on iTunes connect.
    After that, MKStoreKit does the rest.
    Non-consumable and Subscriptions are straight forward. I think I might need to explain a bit about Consumable support.

    Every consumable entry in this plist needs to be a dictionary with “Count” and “Name” defined. Imagine that your app is a fish tank app with eggs, plants and fishes as consumables. Fishes are going to be sold on a per-fish basis. However, you might be interested in selling eggs as discounted basket. To allow this business model, I’ve added a new entry called unique name to every consumable.

    If your products, for example,

    com.myfishapp.eggbasket50 = $2
    com.myfishapp.eggbasket500 = $15
    com.myfishapp.eggbasket5000 = $ 125

    are in fact same in your business (in this case they are all eggs, just that the count is different and subsidized for bulk purchases), you can define them on plist as individual consumable mapping to the same name.
    MKStoreKit will then treat all these products as same when remembering purchases.

    So instead of you remember how many fish eggs this person has purchased, you can leave that task to MKStoreKit. You get a nice wrapper around them and call these methods on MKStoreKit

    - (BOOL) canConsumeProduct:(NSString*) productName quantity:(int) quantity;

    to check for product availability and

    - (BOOL) consumeProduct:(NSString*) productName quantity:(int) quantity;

    to notify MKStoreKit to deduct the consumable’s balance.

    This support was originally added to MKStoreKit 3.5, but it didn’t support product bundles. MKStoreKit v4 adds support for this.

    Subscriptions expiry notification

    MKStoreKit automatically posts notifications when your auto-renewable subscriptions are renewed or failed validation (expired). Observe the following notifications,

    kSubscriptionsPurchasedNotification
    kSubscriptionsInvalidNotification

    on your view controller or AppDelegate and take corresponding actions.

    A note for MKStoreKit 3 users

    MKStoreKit 4 uses keychain to remember purchases. This is partly to support In-App purchases on the upcoming operating system, OS X Lion. On iOS, all apps are sand-boxed and outside access to NSUserDefaults is not possible (unless the device is jail-broken). So remembering purchases on NSUserDefaults was *good enough*. On Lion, however, NSUserDefaults file is just another plist that could be edited on any text editor and technically “buy” our in-app feature. To circumvent this piracy, MKStoreKit 4 will use keychain instead of NSUserDefaults.
    As such if you have any consumables, they will not be automatically migrated to keychain store by MKStoreKit. You should do that part yourself. Non-consumables and Subscriptions doesn’t have this issue.

    Source Code

    The complete source is available on Github

    Demo Project

    There isn’t a demo project available because of the nature in which In-App purchases work.
    The only way would be to create a dummy project from my iTunes store account and create IAP. But that would add maintenance nightmare for me. However, since MKStoreKit is self-contained, you shouldn’t normally have trouble integrating it into the product.

    Licensing

    It’s licensed under Zlib as I feel that’s the most open license ever.

    A word on third-party components

    MKStoreKit uses the following third-party components.

    1. JSONKit by John Engelhart (BSD or Apache Licensed)
    2. NSData base64 encoding additions by Matt Gallagher (Zlib license)
    3. SFHFKeychianUtils by Buzz Andersen

    Final words

    I’m still making some touchups and final set of changes. But I think they will mostly be *cosmetic* (code refactoring). Feel free to pull/fork MKStoreKit and leave your feedback.

    Support me

    Hourly rates of a iPhone developer is skyrocket high. I believe this code would have saved your coding hours by at least a day. You can consider supporting further development by funding me through PayPal.  My PayPal email is mugunth.kumar@gmail.com

    Mugunth

Follow me on Twitter

  • Phil

    Hi,

    Great work on building this IAP framework. For auto-renewable subscriptions of say 6 months, what  should I put in the days field in the plist file, since each months days may vary ?? 180 ?

    Thanks,
      Phil.

  • Jesse

    Seems like a great framework, and your addition of .plist loading for the features is a good idea, however it really should have the flexibility to be able to load that from any file, instead of one in the app bundle.  Being able to update your IAP content list by downloading it from a server without requiring an app update is a critical feature, and one that apple recommends in their documentation.

    Obviously modifying your code to support that is pretty easy now that you use a property list, but it’s puzzling why you’ve decided not to, either with a new delegate callback requesting the filename, or something similar.

  • Mag

    Is there a reason you’re not using a notifier for notifying isSubscriptionActive as you do when it’s invalid?

  • Leshinc

    Hi, Mugunth

    I am using MKStoreKit for Auto-Renewable Subscriptions.

    The system go to confirm shared secret step. After I confirm, the system will not entry onComplete block and onCancelled.

    How can I fix this issue ?

    Help me pls……

  • Martin

    if “kFeatureAId” is an auto-renewable subscription, the “onComplete” is never executed, regardless whether the purchase was successfull or not while “onCancelled” is executed it it failed.

    Any idea how to fix this?

    [[MKStoreManager sharedManager] buyFeature:kFeatureAId
                                    onComplete:^(NSString* purchasedFeature)
     {
         NSLog(@”Purchased: %@”, purchasedFeature);
     }
                                   onCancelled:^
     {
         NSLog(@”User Cancelled Transaction”);
     }];

  • guest

    it’s confusing that you named it “MK”StoreKit, since apple uses that as a prefix for Map Kit.  Just a thought 😀

  • Steve

    Hello Mugunth

    I am very to to objective c, I have written first app, trying to implement in app purchase (an annual subscription) using your MKStoreKit. 

    I am having the same problem as Martin (1 week ago): in the sandbox, if “kFeatureAId” is an auto-renewable subscription, the “onComplete” is never executed, regardless whether the purchase was successfull or not,  while “onCancelled” is executed when the buyer cancels.

    The next time the app is started [MKStoreManager isFeaturePurchased: kFeatureAId] does not recognise that the purchase has been made and pro pmts the user to buy. When the user buys, a message comes up that you already have paid for this subscription.

    Does anyone have any ides what I could be doing wrong?

    • I am facing the same issue. Did you find any solution?

      • Steve

        No

  • Pingback: Cleverson Leal » Rescue City: Prólogo()

  • RafCad

    Hi all,

    Im trying to use the MKStoreKit but im getting the message: “Problem in iTunes connect configuration for product”

    My app its not 100% ready, i didnt submited any code to itunesconnect. My app status is “Prepare for Upload” and my In-App Purchase status is “Ready to submit”.

    Its possible to test at this point? Or i have to do something else?
    My In-App Purchase its from non-consumable time, and the only thing i did its to add it on MkStoreKitConfig.plist. Is that correct?

    Any help would be appreciated.

    • Samidjo

      Hi have the same status, how did you manage to fix it?

  • Pingback: Cleverson Leal » Rescue City: Prologue()

  • Hello,

    Could you please please please make a step by step?

    In none of your posts I saw what the server files are for…

    You could make a wiki on github I would be happy to contribute.

    Thank you

  • Christoph

    Hello all, hello Mugunth,

    I have 2 questions. I implement die MKStoreKit latest version (4.1). It work’s great, but their are two questions to the auto-renewable subscription.

    First: If I buy an auto-renewable subscription in the sandbox an the subscription is inactive, how to renewable my subscription? I search the method. In the Apple Programming Guide I read that I need the restore-method for non-consumable products. How can I do this with MKStoreKit?
    I use this code: [[MKStoreManager sharedManager] restorePreviousTransactionsOnComplete:^ onError:^(NSError *error)] 
    I become more then one restored-status. After I restart my app the subscription all so it is inactive.

    Second: How can I solve the restore-problem with two different devices? I install the app at the first device and buy a subscription on this. After that I install the app on a second device with the same Apple ID. How can I restore my subscription on my second device.

    Thanks for your help.
    Christoph

  • Bu_walid_23

    how to dawnload it ?

  • Peter

    2 questions about the sandbox/buy thing:Where should NDEBUG be defined? I made a release build and the binary contains the sandbox-adress instead of the buy-address.Is the kReceiptValidationURL relevant for non-consumables? if not, I don’t need to set NDEBUG?Thx in advance

  • Marc Cramdal

    Regarding the migration from older versions, you are saying: “As such if you have any consumables, they will not be automatically migrated to keychain store by MKStoreKit. You should do that part yourself. Non-consumables and Subscriptions doesn’t have this issue.”

    However, it looks like there is no code that automatically migrates non-consumable purchases? Am I wrong?

  • Karl

    I don’t know if its apples new policy, but my app has now been rejected for the 3rd time because of this.

    apparently, apple does not like transferring the purchase data to a server, even though I’m not even using it.

    first was my fault.

    second rejection was because in the “verifyProductForReviewAccess” function, you pass the UDID.. apparently this is a no-no, sensitive information. 

    so i comment everything out.

    then they say in the “verifyReceiptOnComplete” you are passing the receipt.. they don’t like that either, because it contains sensitive information.

    so now that i’ve blown more than an entire month in review, and now its xmas shutdown, so I’m TOTALLY out of luck to hit the xmas season. I’m taking this out all together, and just charge for the app.

    be warned anyone using this, stay away unless you have months to debug it.

    • Anonymous

      Apple has changed their policies recently. Hold on, I’m updating this MKStoreKit

      • Vincent

        sam here ! how do you plan to fix this ? thanks in advance.

      • Karl

        I think you will have to remove all the server side stuff. That seems to be what they are complaining about.  Im getting ready to resubmit without the in-app purchasing. hopefully ill re-integrate this on an update someday.

        but right now, its a guaranteed rejection after 3 weeks of “in-review” if you want to use it.

        • Giles

          is this fixed yet?

          • The silence is killing me!

          • Doug

            looks like MKStorekit sends everything in the clear between the server and the iOS device, meaning anyone sniffing would see all the end user’s information.  

            I would imagine the iOS code should send an encrypted blob to the server (since we are not using https due to costs), where the php code should unencrypt. 
            i.e. http://stackoverflow.com/questions/6641693/iphone-encrypt-function-that-would-be-decrypt-on-php-server

            That may be all they care about, but having dealt with apple, they never come out and say how you can SOLVE their complaints, and they only hint as to why they rejected.

            I may fork and add encryption  but I would of course prefer to see Kumar do it :)

          • Anonymous

            If your server is https, encryption happens automatically

          • Doug

            of course.  Are you seeing review rejections from users that had employed https?  I just assumed most people (myself included) want to avoid the cost of https certificates. 

            Apple likely is a bit sheepish providing uuids to insecure servers that can be scraped.  I suggest jumbling the uuid into a large  unique blob as a way to appease them and keep the excellent server feature alive.

            (assuming security is the heart of their rejection)

  • Marin

    Hey Mugunth, awesome code – I’m been using code from the mkstorekit since its very first version :) Just got ver 4 from github and I was wondering whether you forgot to add “return uniqueID;” at line 66 in MKSKProduct.m ? There’s a warning that +(NSString*)deviceId doesn’t return a value when compiling for iOS. Have a look :)

    best, Marin

  • Marin

    If there’s something else coming in from iCloud besides NSString there’s a crash, because SFHFKeychainUtils expects an NSString as the password parameter and calls “dataUsingEncoding” on it. So when some other value comes in from iCloud (NSArray for example) the code crashes there … I added : MKStoreManager.m : 86
            if ([(NSObject*)obj isKindOfClass:[NSString class]]) {

  • Pingback: AppDev by egarce - Pearltrees()

  • Dan

    [[MKStoreManager sharedManager] restorePreviousTransactionsOnComplete:… required for subscriptions to work?

    I have implemented auto-renewable subscriptions with MKStoreKit 4.1. I find that I must run restorePreviousTransactionsOnComplete on every start of the app or the subscription comes up as inactive.
    The app is always starting up with:Receipt Dictionary from Apple Server is invalid: (null)

    Do I need to implement anything else in order to remember the subscriptions so that they are not inactive?

  • Gianluca

    Hello Mugunth,
    I was using your MKStoreKit in an app and have found a weird problem. I tested it on different devices, seems that in my case the purchasing process works well on iOS5, while bad on iOS4.
    Summarizing the test conditions, in both the cases (iOS4 and iOS5),
    a) we ran the app after being logged off from the AppStore.
    b) the app has 1 non-consumable product so the situation is very simple.
    c) keychain and iCloud don’t contain the product related data, as the product has been created from scratch on iTunesConnect before this test (code aligned)
    d) we didn’t confirm the purchasing in the iOS Alert View (so at the end of the test the product is not purchased)

    I did saw the following:
    – On iOS5 everything works correctly, so we can see the iOS Alert View which asks to confirm the purchasing (tested on two devices)
    – On iOS4, after pushing our “Buy” button, the purchasing process starts but nothing happens. What I see is that, inside the productsRequest:didReceiveResponse: of MKStoreManager, the product featureId is inserted in the invalidProductIdentifiers, but without a known reason.

    I don’t know how often this could happen, but in this case the result is that the addToQueue: method returns without completing the purchasing (in fact index == NSNotFound), and there is no way to understand that an error occurred from the caller/UI point of view.

    Question is: do you have any suggestion that could help us on identifying the reason of the problem on iOS4? Maybe it’s our fault.

    Anyway, I would suggest two changes:
    1. to change the addToQueue: method into
           -(BOOL) addToQueue:(NSString*) productId, in order to return something in case of error
    2. to add an onError block to buyFeature: method, in order to give the UI view controller an opportunity to manage the error.

    Thanks a lot in advance (and sorry for the long message)

  • VSDesigner

    I used the older version and it worked just great. Wanted to use 4.0 for the support with Auto Renewable Subscriptions and I have everything setup and everything seems to work just great until the receiptData is verified by Apple. I keep getting a 21004 error response. Which indicates ‘The shared secret you provided does not match the shared secret on file for your account.’, which is not the case.
    I can take that same exact receiptData and share secret and run it via the php script from the older version of MKStoreKit and it comes back success with code 0.

    In the MKStoreKitConfigs.h, I have, tried it with & without . with gets 21004, without gets no response.
    #define kSharedSecret @””

    • Anonymous

      Are you using the shared secret from your iTunes connect?

      Mugunth
      Author | Developer | Trainer
      iOS 5 Programming book
      iBooks: http://mk.sg/ibook
      Amazon: http://mk.sg/ios5book

      • VSDesigner

         Yes I am.

        I use the same share secret in a php script and it works just fine.

  • Dan

    Thanks for MKStoreKit – it’s really great!

    I was wondering under what circumstances do I need to show a “Restore Transactions” button?
    the transactions are now stored in iCloud but there are plenty of devices not on an iCloud enabled iOS version. I imagine everyone will not have it set up either.

    Apart from when isFeaturePurchased returns YES – is there any other time when I can safely hide the “restore transactions” button?

    thanks!

  • Zakhar

    Hello.
    Help me please. I’ve proble with MKStoreKit in my application.
    I include StoreKit.Framework and Security.Framework into my product and folder MKStoreKit (dowloaded from Github), but when I try build my product Xcode show 21 errors in MKSKProduct.h MKSKProduct.m files.
    Thank you.

    • sad face

      i don’t think this code works anymore :(

      • Johnny Slagle

        Is this confirmed?

  • AlanApple

    Thanks Mugunth!
     I’ve used your samples before, and they were great! Thanks soooo much for taking away a lot of pain.
    Alan

  • Valerio

    Thanks for this great lib! I found a little bug in the file MKStoreManager.m in the method addToQueue:.

    Actually, there are these instructions:

    int index = [allIds indexOfObject:productId];        if(index == NSNotFound) return;

    but note that indexOfObject returns a NSUInteger, not a int.

    This could be a problem when none of the objects in the array is equal to productId, because indexOfObject: returns NSNotFound (=NSIntegerMax), but its value it is casted to an int, which means it becomes -1. Consequently, the next if evaluates to NO, and is not done the return.

    Hope this helps!

    • kamarshad

      @93d0b4fb098ab7dbae7f0a959cfe1a73:disqus It means we should use NSUInteger instead of int . is that so?

  • Trainer

    Hello,

    I implement the MKStoreKit 4.1 for a non-renewing subscription. Apple doesn’t accept the auto-renewable one. How I realize the restore? The restorePreviousTransactionsOnComplete-function return “Restored”. But where is the receipt-array with all the receipt and expire-data?

    • fbartolom

      I also tried to implement them but it seems to behave like it is a renewing one by taking into account ends of subscriptions times and refusing to connect to OWN_SERVER if there is an active subscription, even if the user accepts to extend it.

  • Matt L King

    I have added MKStoreKit to an existing app and I keep getting the error “Review request cannot be checked now: (null)”.  I suspect it might be due to the kConsumableFeatureBId in the configuration file.  I understand this to be the product id + the product number.  What is the product number, and where can it be found?

  • Jules

    I’m getting an error dyld: Symbol not found: _OBJC_CLASS_$_NSUbiquitousKeyValueStore caused by the use of 

    NSUbiquitousKeyValueStore in updateFromiCloud etc. I’m running it on an iOS4 device. I need to support iOS4. how can I work around this error ? I’m only wish to use non-consumable at this time.

  • Matt hias

    Hy

    I’ve added the latest code to my project (with ARC / iOS5) and call [MKStoreManager sharedManager] in my AppDelegate.
    When I start now my app on my device, the app hangs during the initialization of the sharedManager 

    static dispatch_once_t oncePredicate;
    dispatch_once(&oncePredicate, ^{    
                _sharedStoreManager = [[self alloc] init];            
                _sharedStoreManager.purchasableObjects = [[NSMutableArray alloc] init]; It never reach the last line to init the purchasableObjects array.Is there something I’ve done wrong?Thx.Matthias

    • MugunthKumar

      Working on MKStoreKit to support iOS simulator and apparently it broke. Update your submodules or get the latest from Github.

      Mugunth
      Author | Developer | Trainer
      iOS 5 Programming book
      iBooks: http://mk.sg/ibook
      Amazon: http://mk.sg/ios5book

      • Matt hias

        I use the latest code from Githib :/

        • MugunthKumar

          I was working on supporting simulator yesterday and pushed the latest two minutes ago.

          • Matt hias

            thx. this solved the problem. Thank you for this great lib :)

  • pravin uttarwar

    Hi, Mugundh,

    In my case when I restore the auto renewable transactions then i got the call restorePreviousTransactionsOnComplete multiple times, so how should i know that restore has completed and i can then process the last transaction receipt?

  • Paulmatos

    Hi Mugunth, first off many thanks for proving the community with such a great resource. I was wondering if anyone on here could help me with a little issue though. I have been using and testing this code for a few weeks now and all was going well. However now it seem to have stopped working. When I try and run [[MKStoreManager sharedManager] buyFeature… the method simply returns “Review request cannot be checked now: (null) and no alert message.

    Back when the code was working I still received this message but I recieved the buy popup a couple of seconds later. Now, however, I never receive the buy alert message. If I wait 1-2 minutes I eventually get an alert message, with no text that just says “dismiss”. Any idea on why this might be happening?

    I have not modified the code at all since it was last working, the only thing I have altered that I think might have broken it would be I added a device to the provision and re-downloaded it. Is this a possible explanation? Could it be something else?

    • MugunthKumar

      This could happen if the In App Purchases are modified. If your app was rejected by Apple, all associated In App purchases will also be rejected. Check the console to see if the In App purchases are enumerated properly

      • Paulmatos

        Hi Mugunth,

        Thank you for the reply. The app has been self rejected in iTunes connect, and it seems to be logging the feature ID’s just fine. Is it possible something is up with the iTunes sandbox servers? The code is now working again, however there is still about a 1 minute delay before I get the “Confirm Purchase” message. Also at the end of day yesterday, I got about 10 dismiss alert messages in a row, as if they are somehow bottlenecking.

  • Loganathan

    Hi mukunth,
                         In this version of 4.0 you said that, instead of using constants in .h file use .plist file to configure our iap product id and its price. It’s fine but my question was in case i am using one separate xml file and on ios app side am downloading that xml file and parsing iap product id’s. Since i can remove and add any new id’s easily  in that xml file and parse it on my ios app. But now if i configured inside the app (plsit) then i can’t remove or add any new iap id’s. Since i need to update the every time if i want to add or remove any iap id’s.

    Thanks,
    loganathan

  • Ghazali013

    Hi Mugunth, 
    I am using your code for inapp purchase but every time i try to purchase an item it ends up with this error massage in – (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions:

    Error Domain=SKErrorDomain Code=0 “Cannot connect to iTunes Store” UserInfo=0x1ca090 {NSLocalizedDescription=Cannot connect to iTunes Store}I am using same product identifier in code as in iTunesConnect.My product are cleared for sale also.plz help me, im suffering for 2 days for this.

  • Jim_wolff

    Simple Question: To get Apple to approve the App with auto-renewable subscriptions do I need to use my own server-side receipt verification as provided by the php code in MKStoreKit or can I just not USE_OWN_SERVER 0? The reason I ask is I did setup the php code and database on my website but the receipt verification is always returning NO and there is no status error, is it supposed to work in the sandbox environment? Since stuff is stored in iClould won’t the purchases, including auto-renewable be able to be restore on multiple iOS devices attached to the same account, as Apple requires to be approved? Meaning I don’t need to figure out why the receipt verification is not working? Thanks…

  • Charlie Williams

    Hi Mugunth, I am looking forward to using this but I can’t seem to get the newest github code to compile… I am getting errors “Type name requires a specifier or qualifier” and “Expected expression” on onReviewRequestVerificationFailed(nil); and onReviewRequestVerificationFailed(nil); in lines 286 and 301 of MKSKProduct.h. How can I fix this?

  • Charlie Williams

    Hmm… 

    onReviewRequestVerificationFailed(); and onReviewRequestVerificationFailed(); compiles. Will this cause problems?

  • swati srivastava

    Unable to restore purchased product.pls help!

  • Antonio

    Hello Mugunth,

    I’m trying to implement a multi-platform app with in-app purchases. I’m using MKStoreKit and non-consumable content. I would use user registration in the server side. The app could be used without registering any user, so it would be possible to download content without being registered.The problem comes because I’m not handling the purchases, but Apple (using Apple ID).If I buy one content with userA, then log in as userB and try to buy the same content, an alert pops up saying something like “You’ve already purchased this In App Purchase but it hasn’t been downloaded.”, how can I handle this?
    If I purchase some content without being registered and then register a user, how can I sent my purchases and bind them with this user only?
    If I buy some content with userA and then change my Apple ID, I won’t own that content anymore according to my Apple ID, how can I handle this kind of situations?It seems a little messy to deal with Apple IDs, registered and non-registered users… It would be easier to buy consumable coins, but I’m afraid of Apple’s rejection.I’m really struggled with this…Thanks for any help.

  • Pingback: In-App Purchase Tutorial And Helper Libraries :: Apps Decoded()

  • Loganathan

    Hi Guys,
                    Here any one facing trouble while implement non-renewing subscription/auto-renewing subscription using mkstorekit4,  Then ping me here. I did it with my ios app. :-)

    mail: loganathans.lmg@gmail.com

  • Pingback: OverCode » Blog Archive » How to Make In App Purchases()

  • Meghan

    Hi,

    Thanks for nice tutorial.

    I am Using MKStoreKit for autorenewable subscription.

    On Button’s TouchUpInside method I am using following code..

    if([[MKStoreManager sharedManager] isSubscriptionActive:kSubscriptionMonthlyIdentifier]){
    //access to subscription feature
    }else{
    //ask user to buy
    }

    It always returns me false. And ask user to buy.

    When I tried to buy again it shows me that You are already subscribed.

    Is there something that I am doing wrong?

    Is there any other method to check if subscription is active or not.

    How should I know that subscription is renewed?

    Any help would be appreciated.

    Thanks in Advance.

    • Tony Chuinard

      I’m not sure, but it might be an issue with ‘NDEBUG’ not being set as a preprocessor macro for release builds. So it’s checking the sandbox server to check a subscription’s validity in production.

  • Murat Turhan

    Hi, I tested my application’s “buy subscription” feature many times with my test account. It works correctly in sandbox. My in-app purchase application was rejected 3 times.And then my application was published at last week. Now, subscription buying is working correctly but there is no “receipt” for subscription. The “buy subscription” window appears for everyone, even for users who have already subscribed for the app. There is no receipt data. All these features worked perfectly during tests. I had to remove my application from sale because of this. Now why are they not working correctly ? Why receipt data always comes null ?

  • Pingback: iOS Tips : สิ่งที่ต้องทำหลัง Add พวกเครื่องมือต่างๆ | MOETOY.COM()

  • Pingback: iOS Tips : สิ่งที่ต้องทำหลัง Add พวกเครื่องมือต่างๆ | MOETOY.COM()

  • Mahaboob

    Hi Mugunth,

    My Application was rejected by apple due to crash in MKStorekit.

    I have implemented non-renewable subscriptions and is working fine in all my devices. But apple review team got crash after launching the application in iPad 3 with iOS 6.0.1 version. I got the crash log as

    Exception Type: EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Crashed Thread: 0

    Last Exception Backtrace:
    (0x33e9429e 0x3ab7697a 0x33e97e02 0x33e9652c 0x33dedf64 0x26dd0 0x2b354 0x2bc4c 0x2ba32 0x33a0a048 0x33dda748 0x33a09fe4 0x33a0a8aa 0x33a0af88 0x33a09b86 0x3bec411a 0x3bec34b2 0x3bec81b8 0x33e67f36 0x33ddaeb8 0x33ddad44 0x3731f2e6 0x39bf82f4 0x4202 0x2c68)

    Thread 0 name: Dispatch queue: com.apple.main-thread
    Thread 0 Crashed:
    0 libsystem_kernel.dylib 0x32dbe350 __pthread_kill + 8
    1 libsystem_c.dylib 0x3ab1511e pthread_kill + 54
    2 libsystem_c.dylib 0x3ab5196e abort + 90
    3 libc++abi.dylib 0x38d1ed4a abort_message + 70
    4 libc++abi.dylib 0x38d1bff4 default_terminate() + 20
    5 libobjc.A.dylib 0x3ab76a74 _objc_terminate() + 144
    6 libc++abi.dylib 0x38d1c078 safe_handler_caller(void (*)()) + 76
    7 libc++abi.dylib 0x38d1c110 std::terminate() + 16
    8 libc++abi.dylib 0x38d1d50e __cxa_throw + 118
    9 libobjc.A.dylib 0x3ab769ba objc_exception_throw + 90
    10 CoreFoundation 0x33e97e02 -[NSObject(NSObject) doesNotRecognizeSelector:] + 166
    11 CoreFoundation 0x33e9652c ___forwarding___ + 388
    12 CoreFoundation 0x33dedf64 _CF_forwarding_prep_0 + 20
    13 MyAppliacation 0x00026dd0 -[MKSKProduct initWithProductId:receiptData:] + 92
    14 MyAppliacation 0x0002b354 -[MKStoreManager provideContent:forReceipt:hostedContent:] + 464
    15 MyAppliacation 0x0002bc4c -[MKStoreManager completeTransaction:] + 124
    16 MyAppliacation 0x0002ba32 -[MKStoreManager paymentQueue:updatedTransactions:] + 166
    17 StoreKit 0x33a0a048 __NotifyObserverAboutChanges + 80

    I have no idea about where i was gone wrong. How can I fix this issue? Please help me to overcome this issue.

    Thanks in adavance

  • how to know if a user has cancelled auto renewable subscription in ios

    • Shubham Kalra

      Hi Jose.

      I am stucked in the same situation, i want to know subscription cancellation event as soon as user cancelled the auto renewing subscription.Could you please guide how to handle this.

  • Priyanka Mistry

    Hi Mugunth,

    Thanks for providing this excellent tutorial.

    I have my app live and I am facing some problem in MKStoreManager.m

    It is working on my device but crashing on user’s device.

    crash report shows me this:

    Date/Time: 2013-02-17T23:18:06Z
    OS Version: iPhone OS 5.1.1 (9B206)
    Report Version: 104

    Exception Type: SIGTRAP
    Exception Codes: #0 at 0x356f5e4c
    Crashed Thread: 0

    Thread 0 Crashed:
    0 CoreFoundation 0x356f5e4c _CFHash + 8
    1 CoreFoundation 0x35771be7 ___CFDictionaryStandardHashKey + 23
    2 CoreFoundation 0x356f4850 _CFBasicHashFindBucket + 1788
    3 CoreFoundation 0x356f4145 _CFDictionaryGetValue + 117
    4 CoreFoundation 0x356f60d7 -[CFXPreferencesSource getValueForKey:] + 43
    5 CoreFoundation 0x35734211 -[CFXPreferencesPropertyListSource setValue:forKey:] + 37
    6 CoreFoundation 0x35734197 __CFXPreferencesSetValue + 135
    7 CoreFoundation 0x35734089 _CFPreferencesSetAppValue + 37
    8 Foundation 0x34b3f45d -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 85
    9 MyApp 0x00017547 -[MKStoreManager provideContent:forReceipt:] (MKStoreManager.m:324)
    10 MyApp 0x00007435 -[MKStoreObserver restoreTransaction:] (MKStoreObserver.m:89)
    11 MyApp 0x00007265 -[MKStoreObserver paymentQueue:updatedTransactions:] (MKStoreObserver.m:65)
    12 StoreKit 0x33c157a7 ___NotifyObserverAboutChanges + 59
    13 CoreFoundation 0x356fbafb _CFArrayApplyFunction + 39
    14 StoreKit 0x33c15763 -[SKPaymentQueue _notifyObserversAboutChanges:] + 119
    15 StoreKit 0x33c15453 -[SKPaymentQueue _addLocalTransactionForPayment:] + 251
    16 StoreKit 0x33c1494d -[SKPaymentQueue addPayment:] + 445
    17 MyApp 0x00017231 -[MKStoreManager buyFeature:] (MKStoreManager.m:234)
    18 MyApp 0x0000e1e9 -[UnlockViewController unlockFeature:] (UnlockViewController.m:193)
    19 CoreFoundation 0x357063fd -[NSObject performSelector:withObject:withObject:] + 53
    20 UIKit 0x32ec7e07 -[UIApplication sendAction:to:from:forEvent:] + 63
    21 UIKit 0x32ec7dc3 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 31
    22 UIKit 0x32ec7da1 -[UIControl sendAction:to:forEvent:] + 45
    23 UIKit 0x32ec7b11 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 493

    I have downloaded app from app store in my device and it is working great.

    But user’s can not open app after in app purchase has made.

    I need to fix this as soon as possible.

    please help…

  • Bhavesh Nai

    Hi,

    Possible monthly inapp Purchase??
    How?