Skip to content

Commit

Permalink
support promouting purchaces
Browse files Browse the repository at this point in the history
simple relese promoting purchace: https://developer.apple.com/app-store/promoting-in-app-purchases/

copy to my old code, from : https://github.com/Valeryn4/Godot-IOS-Services-Extend-Module/tree/dev


add new event "purchase_deferred"
initializing an out-of-game purchase

sample:
```gdscript
while iap.get_pending_event_count() > 0:
		var event = iap.pop_pending_event()
		if event.type == "purchase_deferred" :
			iap.purchase( { "product_id": event.product_id} ) #deferred purchase
```
  • Loading branch information
Valeryn4 authored Apr 21, 2021
1 parent 4229435 commit 6f90954
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugins/inappstore/in_app_store.mm
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ - (void)finishTransactionWithProductID:(NSString *)productID {
self.pendingTransactions[productID] = nil;
}

- (BOOL)paymentQueue:(SKPaymentQueue *)queue shouldAddStorePayment:(SKPayment *)payment forProduct:(SKProduct *)product {
Dictionary ret;
ret["type"] = "purchase_deferred";
ret["result"] = "ok";
ret["product_id"] = String::utf8([payment.productIdentifier UTF8String]);
InAppStore::get_singleton()->_post_event(ret);
return false;
}

- (void)reset {
[self.pendingTransactions removeAllObjects];
}
Expand Down

0 comments on commit 6f90954

Please sign in to comment.