Skip to content

Commit fc5952a

Browse files
authored
Merge pull request #42 from novalis/iap-restore
Send completed message at end of iap restores.
2 parents 08a840e + baf6002 commit fc5952a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

plugins/inappstore/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var _appstore = null
1010
func check_events():
1111
while _appstore.get_pending_event_count() > 0:
1212
var event = inappstore.pop_pending_event()
13-
if event.result=="ok": # other possible values are "progress", "error", "unhandled"
13+
if event.result=="ok": # other possible values are "progress", "error", "unhandled", "completed"
1414
1515
# print(event.product_id)
1616
match event.type:
@@ -21,7 +21,12 @@ func check_events():
2121
# fields: product_id, transaction_id, receipt
2222
...
2323
'restore':
24-
# fields: product_id, transaction_id, receipt
24+
# fields: product_id, transaction_id, receipt
25+
...
26+
'completed':
27+
# Now the last in-app purchase restore has been sent,
28+
# so if you didn't get any, the user doesn't have
29+
# any purchases to restore.
2530
...
2631
2732
func _on_Purchase_button_down():

plugins/inappstore/in_app_store.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,21 @@ - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)tran
344344
}
345345
}
346346

347+
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
348+
Dictionary ret;
349+
ret["type"] = "restore";
350+
ret["result"] = "completed";
351+
InAppStore::get_singleton()->_post_event(ret);
352+
}
353+
354+
- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error {
355+
Dictionary ret;
356+
ret["type"] = "restore";
357+
ret["result"] = "error";
358+
ret["error"] = String::utf8([error.localizedDescription UTF8String]);
359+
InAppStore::get_singleton()->_post_event(ret);
360+
}
361+
347362
@end
348363

349364
void InAppStore::_bind_methods() {

0 commit comments

Comments
 (0)