robotmedia / RMStore

A lightweight iOS library for In-App Purchases
Apache License 2.0
2.42k stars 450 forks source link

Best Way to Check Auto Renewable Subscription is still Active? if Yes then Active Premium Features.. #189

Open qasimmehboob opened 8 years ago

qasimmehboob commented 8 years ago

What is best way to check Auto Renewable Subscription is still active? if it is active then enable premium features of App ? and what is the best place to do it ? in App Delegate ? Or In viewDidLoad() of first viewcontroller display to user when app launched.

danielgalasko commented 8 years ago

@qasimmehboob refresh the receipt and inspect expiration date. Do it whenever you feel its pertinent. We check on app startup:) http://savvyapps.com/blog/how-setup-test-auto-renewable-subscription-ios-app theres some reading for you

qasimmehboob commented 8 years ago

@danielgalasko sorry for late reply. i was busy some other things. what do you mean by app startup ? Do you mean In AppDelegate.m function
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { }

In current version of my app i am checking like this: i am calling the fowling code in viewDidLoad() of very first ViewController.

- (void)viewDidLoad {
    BOOL isActive = false;
    RMAppReceipt *appReceipt = [RMAppReceipt bundleReceipt];
    if (appReceipt) {
          isActive =  [appReceipt containsActiveAutoRenewableSubscriptionOfProductIdentifier:XXXXXXX forDate:[NSDate date]];
        }
    if (isActive) {
         // Enable Premium Features
    }
    else {
        // Disable Premium Features
    }

Please guide me properly. i am new to this and i do not any senior developer in my friends circle.

danielgalasko commented 8 years ago

@qasimmehboob its difficult to guide without an understanding of your App but that should be good enough.

I typically like having my own SubscriptionCenter class that handles all relevant business logic and conceals all 3rd party code so its easier to replace RMStore if you want to at a later point.

Doing it in viewDidLoad is alright, as long as you allow the user to restore purchases and then check the receipt again after that you are golden:)

qasimmehboob commented 8 years ago

@danielgalasko: i have uploaded a beta version of my app to app store. The link to app is this [https://itunes.apple.com/us/app/scanx-pdf-document-scanner/id1123617187?ls=1&mt=8] . I uploaded this version only for testing whether apple accept or reject my app. i'll upload a new refine version in one or two days. You can take a look at my app and give me feedback about Auto Renewable Subscription. it'll be very helpful for me.

ErMaheshwari commented 7 years ago

@qasimmehboob , I just read about your subscriptions, would like to know is it working fine?, I am actually implementing the auto renewal subscriptions, and have questions , to receipt validation and and refresh receipt.