私はこの技術をiOS6、iOS7、iOS8でテストしたところ、すべてうまく見えます。
- (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];
}
お返事ありがとうございました。実際に、支払いが成功すると、支払い代理人(私のSKPaymentTransactionObserverクラス)に通知されます。その時点で私は製品を提供してトランザクションを終了しますが、その後に起こることは私が制御できないものです...そして、それはダイアログボックスが表示されたときです。それはあなたが何を意味していたのですか? – Chico
それは私が言ったことです。アラートを却下したり、アラートを変更することはできません。 –
しかし、プロセス全体がいつ終了するかを知る方法はあります。そのアラートに干渉するのではなく、ユーザーが大丈夫だと知っているかどうかを少なくとも知るために、いいえ? –