Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-23-2011, 07:09 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 144
iAppDev is on a distinguished road
Default in app purchase resets HELP PLZ

ok so I got to make in app purchase for my app and it all works and unlocks the features that i want, but the sucky part is that whenever i get out of the main view (view1) and load another view(view2), when i come back to main view (view1), the stupid in app purchase is locked again.
the only way i can reunlock it is if i purchase it again. of course it says it's free download.

how can i make it so that when the app loads or comes from another view, it should be unlocked already if previously purchased (and i don't mean if the app is redownload it, just when it comes from another view).

thanks in advance guys.

here's my codes that i have

Code:
//the action that unlocks it and is set hidden after purchase
-(IBAction)purchaseAction{
    
    SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"partypack03"];
    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
    [[SKPaymentQueue defaultQueue] addPayment:payment];
    
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
    SKProduct *validProduct = nil;
    int count = [response.products count];
    if (count > 0) {
        validProduct = [response.products objectAtIndex:0];
    }
    else if (!validProduct){
        NSLog(@"no in app purchase available");
    }
    
}


- (void) paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
    for (SKPaymentTransaction *transaction in transactions) {
        switch (transaction.transactionState) {
            case SKPaymentTransactionStatePurchasing:
                NSLog(@"purchaseding");

                break;
            case SKPaymentTransactionStatePurchased:
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

                purchased3player.hidden = YES;
                purchased4player.hidden = YES;
                
                NSLog(@"purchased show unlock");
                

                break;
                
            case SKPaymentTransactionStateRestored:
                NSLog(@"stay unlock after reset");
                purchased3player.hidden = YES;
                purchased4player.hidden = YES;


                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

                break;
                
            case SKPaymentTransactionStateFailed:
                if (transaction.error.code != SKErrorPaymentCancelled) {
                    NSLog(@"payment error");
                }
                [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

                break;
        }
        if (transaction.transactionState != SKPaymentTransactionStatePurchasing) {
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
        }

    }
}

//inside the viewDidLoad
    //load in app purchase
    if ([SKPaymentQueue canMakePayments])
    {
        // Display a store to the user.
        NSLog(@"parental control Disabled. You can purchase");
        SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.appstreetboys.AlmaDesnudaSpecialEdition"]];
        productsRequest.delegate = self;
        [productsRequest start];
        
    }
    else
    {
        // Warn the user that purchases are disabled.
        NSLog(@"parental control enabled. You can't purchase");
    }
iAppDev is offline   Reply With Quote
Old 11-23-2011, 08:28 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

You need to record somehow (NSUserDefaults) for example that the item has been purchased and the first check if this record exists. If it does, provide the functionality, if not, show the screen to purchase. NSUserDefaults isn't the most secure way to store this, but if you aren't worried about piracy too much it'll do.
baja_yu is offline   Reply With Quote
Old 11-24-2011, 01:41 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 144
iAppDev is on a distinguished road
Default

how do i use the NSUserDefault? i have no idea. please help if you know or where do i need to implement it. thanks

EDIT: lol sorry i know how to use that feature but is there any other way for me to implement that if a in app purchase has been purchased and the app is restarted or coming from another view, it should still be unlocked. thanks

Last edited by iAppDev; 11-24-2011 at 01:44 PM.
iAppDev is offline   Reply With Quote
Old 11-24-2011, 01:48 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

You should look at MKStoreKit, everything is already built and waiting for you to use.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 399
16 members and 383 guests
chiataytuday, Clouds, David-T, dedeys78, Duncan C, e2applets, EvilElf, iekei, ipodphone, leostc, LunarMoon, Murphy, QuantumDoja, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:38 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0