Play store alerts

When one of my transactions in the application is completed, either because it has been restored, or because it is a successful purchase, the Store Kit generates a warning that displays a confirmation dialog. This current version says, "Thank you, your purchase was successful."

Since my application should go to another screen after a successful purchase, I want to intercept this dialog box and not proceed until the user misses it. The problem is that I do not seem to control this dialog box. Anyone have any ideas how to do this?

Thank!

+3
source share
3 answers

. - . AppStore.app , .

+4

, , StoreKit:

activeState UIApplication , "", , "" ( UIApplicationDidBecomeActive).

'activeState' 4.0, .

+2

I tested this technique with iOS6, iOS7 and iOS8, and everything seems to be fine.

- (void) activeShow;
{
    UIApplication *app = [UIApplication sharedApplication];
    if (app.applicationState == UIApplicationStateActive) {
        [self finishActiveShow];
    } else  {
        [[NSNotificationCenter defaultCenter] addObserver:self
                selector:@selector(becomeActiveNotification:)
                name:UIApplicationDidBecomeActiveNotification object:nil];
    }
}

- (void) finishActiveShow;
{
    if (self.beforeShow) {
        self.beforeShow();
    }
    [self.alert show];
    if (self.afterShow) {
        self.afterShow();
    }
}

- (void) becomeActiveNotification:(id) sender;
{
    SPASLog(@"UIApplicationDidBecomeActiveNotification: %@", sender);
    // From https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Notifications/Articles/NotificationCenters.html
    // "In a multithreaded application, notifications are always delivered in the thread in which the notification was posted, which may not be the same thread in which an observer registered itself."
    // So, it seems that we may not get the notification on the main thread.
    dispatch_async(dispatch_get_main_queue(), ^{
        [self finishActiveShow];
    });

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
}
+1
source

Source: https://habr.com/ru/post/1778019/


All Articles