Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7639839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:31:31+00:00 2026-05-31T08:31:31+00:00

i am having an application with inapp purchase,i completed the code side of inapp,there

  • 0

i am having an application with inapp purchase,i completed the code side of inapp,there is a buy button in my viewcontroller ,when the user tap the this button it go through the payment process,if the payment received is sucess ,i just need to enable a button just beside the buy button.i get the alert that payment sucess ,if the payment is sucess i need to enable a button,that i was disabled earlier.
in button click

 if ([SKPaymentQueue canMakePayments]) {
                     // Yes, In-App Purchase is enabled on this device!
                     // Proceed to fetch available In-App Purchase items.

                     // Replace "Your IAP Product ID" with your actual In-App Purchase Product ID,
                     // fetched from either a remote server or stored locally within your app. 
                     SKProductsRequest *prodRequest= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: @"com.mycompny.myproduct"]];
                     prodRequest.delegate = self;
                     [prodRequest start];
                     // Replace "Your IAP Product ID" with your actual In-App Purchase Product ID.
                     SKPayment *paymentRequest = [SKPayment paymentWithProductIdentifier: @"com.mycompny.myproduct"]; 

                     // Assign an Observer class to the SKPaymentTransactionObserver,
                     // so that it can monitor the transaction status.
                     [[SKPaymentQueue defaultQueue] addTransactionObserver:inappObserver];

                     // Request a purchase of the selected item.
                     [[SKPaymentQueue defaultQueue] addPayment:paymentRequest];

                 } else {
                     // Notify user that In-App Purchase is disabled via button text.
                     [inappButton setTitle:@"In-App Purchase is Disabled" forState:UIControlStateNormal];
                     inappButton.enabled = NO;

i need to enable a button named _btnunlockfeature

in inapppurchaseobserver.m

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
    for(SKPaymentTransaction *transaction in transactions) {
        switch (transaction.transactionState) {

            case SKPaymentTransactionStatePurchasing:
                // Item is still in the process of being purchased
                break;

            case SKPaymentTransactionStatePurchased:
                // Item was successfully purchased!

                // --- UNLOCK FEATURE OR DOWNLOAD CONTENT HERE ---
                // The purchased item ID is accessible via 
                // transaction.payment.productIdentifier

                // After customer has successfully received purchased content,
                // remove the finished transaction from the payment queue.
                [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
                break;

            case SKPaymentTransactionStateRestored:
                // Verified that user has already paid for this item.
                // Ideal for restoring item across all devices of this customer.

                // --- UNLOCK FEATURE OR DOWNLOAD CONTENT HERE ---
                // The purchased item ID is accessible via 
                // transaction.payment.productIdentifier

                // After customer has restored purchased content on this device,
                // remove the finished transaction from the payment queue.
                [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
                break;

            case SKPaymentTransactionStateFailed:
                // Purchase was either cancelled by user or an error occurred.

                if (transaction.error.code != SKErrorPaymentCancelled) {
                    // A transaction error occurred, so notify user.
                }
                // Finished transactions should be removed from the payment queue.
                [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
                break;
        }
    }
}

in the above code the

case SKPaymentTransactionStatePurchased:
                    // Item was successfully purchased!

                    // --- UNLOCK FEATURE OR DOWNLOAD CONTENT HERE ---
                    // The purchased item ID is accessible via 
                    // transaction.payment.productIdentifier

                    // After customer has successfully received purchased content,
                    // remove the finished transaction from the payment queue.
                    [[SKPaymentQueue defaultQueue] finishTransaction: transaction];

i think here i want to write the enabled code ,this code is in NSobject not in the same viewcontroller.please help me to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:31:33+00:00Added an answer on May 31, 2026 at 8:31 am
    //
    - (void)completeTransaction:(SKPaymentTransaction *)transaction
    {
        [self recordTransaction:transaction];
        [self provideContent:transaction.payment.productIdentifier];
        [self finishTransaction:transaction wasSuccessful:YES];
    
    }
    
    
    - (void)finishTransaction:(SKPaymentTransaction *)transaction wasSuccessful:(BOOL)wasSuccessful
    {
        // remove the transaction from the payment queue.
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
    
        NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:transaction, @"transaction" , nil];
        if (wasSuccessful)
        {
    
            // send out a notification that we’ve finished the transaction
            [[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerTransactionSucceededNotification object:self userInfo:userInfo];
    
                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Content successfully purchased" message:nil delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
                [alert show];
                [alert release];
                count = 1;
    
        }
        else
        {
            // send out a notification for the failed transaction
            [[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerTransactionFailedNotification object:self userInfo:userInfo];
        }
    
    
    }
    
    
    
    - (void)provideContent:(NSString *)productId
    {
        if ([productId isEqualToString:kInAppPurchaseProUpgradeProductId])
        {
            // enable the pro features
            // Save the Value stating user Did purchase Sound Pack
            NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
            [defaults setBool:YES forKey:@"SoundPack"];
            [defaults synchronize];
        }
    }
    

    I do it like this..Storing in the NSUserDefaults..and retrieving this in ViewController

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a multi-user application having some critical data of the users. I am
i am having application running on os3.0 i need to adopt this for ios4.0
I am having an application (.apk). I'll give you one flow. When you tap
I am having an application where there are alot of divs with elements inside
I'm having problems serving web fonts through Rails 3.1, within a Spree 0.70 application
I am having application in which i am using menu , on tap on
We are having an application developed for BlackBerry - a pretty big one only.
I am having an application that will be installed on various machines. Now if
i am having a application where i am generating the uibuttons dynamically want to
What are pros and cons of having dedicated application pools over keeping web applications

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.