Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 11    Views: 108

Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
08/14/13 06:10 AM (12 years ago)

WORKING! - Easy In App Purchase Plugin TWEAKS

Not sure if anyone else had noticed but if you make a purchase using the InApp purchase plugin, it works fine until you iDevice has no data connection. Then you get the please wait spinner for ever and ever and ever whilst tryng to load a screen that you have purchased. This leads to unhappy users not being able to play with something they have purchased Now this fix may be simple for alot of you, but for me and my 0% programming skills, it tool be a while to step through code. This is what worked for me..... In the Easy_in_app_purchase.m file and under the -(void)viewDidAppear....... look for the following code: if ([self isAlreadyPurchasedShouldGoToScreen:NO] && !purchasePageFlag) { // purchased product and hasn't come back from purchase page [BT_debugger showIt:self theMessage:@"product already purchased"]; } and change it to this: if ([self isAlreadyPurchasedShouldGoToScreen:NO] && !purchasePageFlag) { // purchased product and hasn't come back from purchase page [BT_debugger showIt:self theMessage:@"product already purchased"]; [self goToPurchasedScreen]; } Its not the best solution because if you then press 'back' from the purchased screen, you still see the spinner spinning and you have to press back again to get to previous screen. Any better solutions that people have then id be more than happy to know but at least now my users can get to 'stuff' they have purchased no matter the connection status of their iDevice Hope this is of some help to someone
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
08/14/13 06:16 AM (12 years ago)
OK, so ive also worked out how to switch off the 'Please wait' spinner at that point. Use the code: if ([self isAlreadyPurchasedShouldGoToScreen:NO] && !purchasePageFlag) { // purchased product and hasn't come back from purchase page [BT_debugger showIt:self theMessage:@"product already purchased"]; [self.pleaseWait setHidden:YES]; [self goToPurchasedScreen]; } Now all i need to know is how to possibly hide the InApp purchase screen on the way back from the Purchased Screen.......
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/14/13 06:37 AM (12 years ago)
Coolness! Thanks for the tips! Cheers! -- Smug
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
08/14/13 07:29 AM (12 years ago)
awesome! i guess i didn't understand your question in the previous post. Great work and share!
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
08/14/13 07:40 AM (12 years ago)
OK, me again....... seem to have it all working now.....even the back button bypassing the purchase screen. (shame it pops up fractionally whilst jumping through screens) Again, in the Easy_in_app_purchase.m file and under the -(void)viewDidAppear....... use this code: if ([self isAlreadyPurchasedShouldGoToScreen:NO] && !purchasePageFlag) { // purchased product and hasn't come back from purchase page [BT_debugger showIt:self theMessage:@"product already purchased"]; [self.pleaseWait setHidden:YES]; [self goToPurchasedScreen]; } else { // hasn't purchased yet and not coming back from purchase page if ([self isAlreadyPurchasedShouldGoToScreen:NO]) { [BT_debugger showIt:self theMessage:@"product not purchased yet"]; [self goToPreviousScreen]; } } also in the same screen add the following code below the -(void)goToPurchasedScreen section: -(void)goToPreviousScreen { [BT_debugger showIt:self theMessage:@"sending to previous screen"]; [BT_viewControllerManager handleLeftButton:screenData]; } Seems to be working for me :)
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
08/14/13 02:06 PM (12 years ago)
Me again. I hope this helps a few out. The below does the following: 1. Skips the user directly to the purchased page if a purchase has already been made 2. Bypasses the inApp purchase screen when the user hits 'back' from the purchased screen 3. Alerts the user that they cannot purchase if their device has no data connection, preventing the please wait spinner getting stuck Replace everything in the //View will appear in the easy in app purchase.m file with the below //view will appear -(void)viewDidAppear:(BOOL)animated{ [super viewWillAppear:animated]; [BT_debugger showIt:self theMessage:@"viewWillAppear"]; // if the user has already purchased, then [self isAlreadyPurchasedShouldGoToScreen:NO]; //flag this as the current screen racenight_appDelegate *appDelegate = (racenight_appDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.rootApp.currentScreenData = self.screenData; //setup navigation bar and background [BT_viewUtilities configureBackgroundAndNavBar:self theScreenData:[self screenData]]; if ([self isAlreadyPurchasedShouldGoToScreen:NO] && !purchasePageFlag) { // purchased product and hasn't come back from purchase page [BT_debugger showIt:self theMessage:@"product already purchased"]; [self.pleaseWait setHidden:YES]; [self goToPurchasedScreen];} else{ if ([self isAlreadyPurchasedShouldGoToScreen:NO]){ [BT_debugger showIt:self theMessage:@"product not purchased yet"]; [self goToPreviousScreen];} else{ [BT_debugger showIt:self theMessage:@"product not purchased yet - checking data connection"]; Reachability *networkReachability = [Reachability reachabilityForInternetConnection]; NetworkStatus networkStatus = [networkReachability currentReachabilityStatus]; if (networkStatus == NotReachable) { NSLog(@"There IS NO internet connection"); [self.pleaseWait setHidden:YES]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection" message:@"InApp purchases cannot be made whilst you have no data connection" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; [alert release]; [self.buyButton setTitle:@"Offline" forState:UIControlStateNormal]; [self.restoreButton setTitle:@"Offline" forState:UIControlStateNormal]; [self.buyButton setEnabled:NO]; [self.restoreButton setEnabled:NO]; }}} //delay the loading of the image so it does not stall the UI if coming from a URL... [self performSelector:(@selector(loadProductImage)) withObject:nil afterDelay:0.3]; } and also add -(void)goToPreviousScreen { [BT_debugger showIt:self theMessage:@"sending to previous screen"]; [BT_viewControllerManager handleLeftButton:screenData]; } below the -(void)goToPurchasedScreen section
 
awesome123
Aspiring developer
Profile
Posts: 132
Reg: Dec 27, 2011
location unknow...
2,320
like
08/16/13 09:06 AM (12 years ago)
awesome! I will try this out! thanks Bonzo
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
12/20/13 06:20 AM (12 years ago)
@Bonzo, now that I have IAP working, this looks like it would improve things a lot. I am running BT 3.0, I tried to install the code from just your last post as I thought it was the sum of all the other fixes. It didn't work. Could you confirm for a coding newbie - should I be installing each fix one after the other from the start please? Thanks Alan
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
12/20/13 06:30 AM (12 years ago)
Last one should be it all but this was prior xcode 5 and ios7. Not played since the upgrade so might need an update. I'll have a play over xmas
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
12/20/13 06:35 AM (12 years ago)
Cheers. I did a cut & paste, changed my appdelegate name, but the other errors floored me!
 
Craig Conover
Aspiring developer
Profile
Posts: 56
Reg: Jan 01, 2013
Menlo Park, CA
4,310
like
01/05/14 03:02 AM (11 years ago)
Is there a estimate on when this plugin will work with BT3.0? Cheers Craig
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
01/05/14 10:29 AM (11 years ago)
I'm not the developer. We need 'theMonster' to update this for us. Not seen him on the forum for some time though
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.