views:

223

answers:

1

Hey evveryone, this is first time for me here, but not last i can see from all the good questions answered here :D

Here is my question: Im about ot make a new iphone app and would like to use In-App-purchase in it. Im a one man developer, so i dont have a server to hold all the packages, so urban airship is just something that fits me :) http://urbanairship.com/

I have tried there sample code, and seems pretty easy, i just cant figure out how to use the data you buy (download) with in-app purchase.

The user have a tableview with, lets say 6 rows, and when the user buy a package in the in app store, there needs to be added 4 more rows. When a user touch a row, lets say the background image will change. Is that possible? and is it easy?

Anyone have expirence with this? i cant seem to find a full sample code of an in app store (where u can download/buy packages, for testing).

Any help would be appreciated :D

  • Drudoo
+1  A: 

When somebody buys something, the Urban Airship StoreFront will call you back with a productPurchased message; if you don't have any content to download, you could use that method to set a flag in your app.

More usually, you'll want to wait to unlock the new options in your app until the content has been downloaded and unzipped.

So say your extra four rows have files image7.png, image8.png, image9.png, image10.png that are the extra content you've downloaded: you can do something like this:

BOOL extraContentUnlocked;

- (void) checkForPurchases {

    NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,                                        NSUserDomainMask, YES) 
                         objectAtIndex:0];

    extraContentUnlocked = [[NSFileManager defaultManager] fileExistsAtPath:[docsDir stringByAppendingString:@"/image10.png"]];
}

and then in your tableView code you can change how many rows there are based on the flag. (if the table view is showing while the extra content is downloading, you might want a timer to keep rechecking whether the new content has arrived so you can refresh the table at the appropriate time.)

David Maymudes
That sounds like something i could use :D thanks, will try that :)
Drudoo
Hmm not working :s I have an image IMG_0713.PNG and when i purchase the content i have an image view where the img should be shown:- (void) checkForPurchases { NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; extraContentUnlocked = [[NSFileManager defaultManager] fileExistsAtPath:[docsDir stringByAppendingString:@"/IMG_0713.PNG"]]; if(extraContentUnlocked) { image2.image = [UIImage imageWithContentsOfFile:@"IMG_0713.PNG"]; } else { NSLog(@"not working!"); }}But i just get the "not working" :(
Drudoo
has your download completed? You may want to use the Organizer in XCode to download the contents of your app's directory so you can look and see if the file actually got there and if so where it ended up... also: you may need to use a more complete path name in your imageWithContentsOfFile
David Maymudes