Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore app is not available on In App Purchase extension #6226

Closed
1 task done
konguele opened this issue Jan 19, 2024 · 1 comment
Closed
1 task done

Restore app is not available on In App Purchase extension #6226

konguele opened this issue Jan 19, 2024 · 1 comment

Comments

@konguele
Copy link

Is there an existing issue for this?

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

@ClementPasteau
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants