Skip to content

Commit

Permalink
Merge pull request #42 from novalis/iap-restore
Browse files Browse the repository at this point in the history
Send completed message at end of iap restores.
  • Loading branch information
akien-mga authored Apr 12, 2023
2 parents 08a840e + baf6002 commit fc5952a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugins/inappstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var _appstore = null
func check_events():
while _appstore.get_pending_event_count() > 0:
var event = inappstore.pop_pending_event()
if event.result=="ok": # other possible values are "progress", "error", "unhandled"
if event.result=="ok": # other possible values are "progress", "error", "unhandled", "completed"
# print(event.product_id)
match event.type:
Expand All @@ -21,7 +21,12 @@ func check_events():
# fields: product_id, transaction_id, receipt
...
'restore':
# fields: product_id, transaction_id, receipt
# fields: product_id, transaction_id, receipt
...
'completed':
# Now the last in-app purchase restore has been sent,
# so if you didn't get any, the user doesn't have
# any purchases to restore.
...
func _on_Purchase_button_down():
Expand Down
15 changes: 15 additions & 0 deletions plugins/inappstore/in_app_store.mm
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,21 @@ - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)tran
}
}

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
Dictionary ret;
ret["type"] = "restore";
ret["result"] = "completed";
InAppStore::get_singleton()->_post_event(ret);
}

- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error {
Dictionary ret;
ret["type"] = "restore";
ret["result"] = "error";
ret["error"] = String::utf8([error.localizedDescription UTF8String]);
InAppStore::get_singleton()->_post_event(ret);
}

@end

void InAppStore::_bind_methods() {
Expand Down

0 comments on commit fc5952a

Please sign in to comment.