Restore app is not available on In App Purchase extension
konguele opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hello,
Apple for iOS tells me that the Restore of the purchase must be included:
Guideline 3.1.1 - Business - Payments - In-App Purchase
We still found that your app offers in-app purchases that can be restored but does not include a "Restore Purchases" feature.
To restore previously purchased in-app purchase products, it would be appropriate to provide a "Restore" button and initiate the restore process when the "Restore" button is tapped by the user.
Please see attached screenshots for details.
I created this part of the code, but it didn't work, is there a way to do it?
- (IBAction)restore:(UIBarButtonItem *)sender {
// Calls StoreObserver to restore all restorable purchases.
[[StoreObserver sharedObserver] restore];
}
InAppPurchase.m file:
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
@interface StoreObserver : NSObject <SKPaymentTransactionObserver>
+ (instancetype)sharedObserver;
- (void)restore;
@end
InAppPurchase.m file
#import "InAppPurchase.h"
@implementation StoreObserver
+ (instancetype)sharedObserver {
static StoreObserver *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:sharedInstance];
});
return sharedInstance;
}
- (void)restore {
// Initiate the restore process
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
#pragma mark - SKPaymentTransactionObserver
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray<SKPaymentTransaction *> *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStateRestored:
// Handle the restored transaction
[self handleRestoredTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
// Handle the failed transaction
[self handleFailedTransaction:transaction];
break;
// Add more cases as needed
default:
break;
}
}
}
- (void)handleRestoredTransaction:(SKPaymentTransaction *)transaction {
// Implement the logic to process the restored transaction
// For example, unlock content, update UI, etc.
}
- (void)handleFailedTransaction:(SKPaymentTransaction *)transaction {
// Implement the logic to handle a failed transaction
// For example, show an error message to the user
}
@end
Steps to reproduce
When you buy an item, you delete the app and it does not ask you to restore when you install it again.
GDevelop platform
Desktop
GDevelop version
5.3.186
Platform info
OS (e.g. Windows, Linux, macOS, Android, iOS)
OS Version (e.g. Windows 10, macOS 10.15)
Browser(For Web) (e.g. Chrome, Firefox, Safari)
Device(For Mobile) (e.g. iPhone 12, Samsung Galaxy S21)
Additional context
No response
InAppPurchase is an extension available here: https://github.com/GDevelopApp/GDevelop-extensions/blob/main/extensions/reviewed/InAppPurchase.json
You shouldn't need to write swift code and can just interact with the package included in the extension (https://github.com/j3k0/cordova-plugin-purchase)
The extension is know to have some flaws and missing features, feel free to update it / submit new actions and conditions for the community.