ios - In App Purchase - No purchase to restore -
i'm trying figure out if message when user tries restore in app purchase there no purchase ever made.
right now, user taps restorebutton
, disable restorebutton
.
- (ibaction)purchaserestore:(id)sender { nslog(@"4 ibaction purchase restore method: start"); [[skpaymentqueue defaultqueue] addtransactionobserver:self]; [[skpaymentqueue defaultqueue]restorecompletedtransactions]; nslog(@"4 purchase restore: skpayment queue 2 lines... log in user"); restorebutton.enabled = no; nslog(@"4 restore button enabled: no"); }
so if click restorebutton
, , have nothing restore restorebutton
stays grayed out.
i uialert
or change restorebutton
text if happens "you don't have items restore", assume need message apple saying "no items restore" can fire off code.
here's updatedtransactions
code if needed:
case skpaymenttransactionstaterestored: [[skpaymentqueue defaultqueue] finishtransaction:transaction]; nslog(@"5 finish transaction"); restorebutton.hidden = yes; nslog(@"5 restore button hidden: yes"); [self showbuttonthree]; nslog(@"5 show button three"); nslog(@"5 restored: end"); break;
any ideas? thanks!
update
tried this:
- (void)paymentqueuerestorecompletedtransactionsfinished:(skpaymentqueue *)queue { nslog(@"completed transactions finished"); uialertview *alertview = [[uialertview alloc]initwithtitle: @"restored succesfully" message:nil delegate: self cancelbuttontitle:@"ok" otherbuttontitles: nil]; [alertview show]; }
but popping whether there transaction restore or not. had assumed called if there no transaction restore maybe, makes sense wouldn't:
-(void)paymentqueue:(skpaymentqueue *)queue restorecompletedtransactionsfailedwitherror:(nserror *)error { nslog(@"completed transactions failed error"); uialertview *alertview = [[uialertview alloc]initwithtitle: @"not restored succesfully" message:nil delegate: self cancelbuttontitle:@"ok" otherbuttontitles: nil]; [alertview show]; }
from official apple documentation restorecompletedtransactions
after transactions delivered, payment queue calls observer’s
paymentqueuerestorecompletedtransactionsfinished:
method. if error occurred while restoring transactions, observer notified throughpaymentqueue:restorecompletedtransactionsfailedwitherror:
method.
Comments
Post a Comment