From 5db294bdb3c3a6e8896300bdd6ab37d1aefe760c Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sat, 23 May 2020 19:58:47 -0400 Subject: [PATCH] Show purchase transaction failures to the user. --- platform-darwin/Source/MPAppDelegate_InApp.m | 15 +++++++++++++-- platform-darwin/Source/MPAppDelegate_Key.m | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/platform-darwin/Source/MPAppDelegate_InApp.m b/platform-darwin/Source/MPAppDelegate_InApp.m index f33bd558..0d58848c 100644 --- a/platform-darwin/Source/MPAppDelegate_InApp.m +++ b/platform-darwin/Source/MPAppDelegate_InApp.m @@ -158,13 +158,13 @@ PearlAssociatedObjectProperty( NSMutableArray*, ProductObservers, productObserve - (void)request:(SKRequest *)request didFailWithError:(NSError *)error { - MPError( error, @"StoreKit request (%@) failed.", request ); + MPError( error, @"StoreKit request failed." ); #if TARGET_OS_IPHONE PearlMainQueue( ^{ UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Purchase Failed" message: strf( @"%@\n\n%@", error.localizedDescription, - @"Ensure you are online and try logging out and back into iTunes from your device's Settings." ) + @"Could not reach Apple's iTunes Store. Make sure you're connected to the Internet and try again." ) preferredStyle:UIAlertControllerStyleAlert]; [controller addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; [self.window.rootViewController presentViewController:controller animated:YES completion:nil]; @@ -222,6 +222,17 @@ PearlAssociatedObjectProperty( NSMutableArray*, ProductObservers, productObserve MPError( transaction.error, @"Transaction failed: %@.", transaction.payment.productIdentifier ); [queue finishTransaction:transaction]; +#if TARGET_OS_IPHONE + PearlMainQueue( ^{ + UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Purchase Failed" message: + strf( @"%@\n\n%@", transaction.error.localizedDescription, + @"Could not reach Apple's iTunes Store. Make sure you're connected to the Internet and try again." ) + preferredStyle:UIAlertControllerStyleAlert]; + [controller addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; + [self.window.rootViewController presentViewController:controller animated:YES completion:nil]; + } ); +#endif + SKProduct *product = self.products[transaction.payment.productIdentifier]; [Countly.sharedInstance recordEvent:@"purchase" segmentation:@{ @"id": product.productIdentifier, diff --git a/platform-darwin/Source/MPAppDelegate_Key.m b/platform-darwin/Source/MPAppDelegate_Key.m index 3b032dfc..fd771b59 100644 --- a/platform-darwin/Source/MPAppDelegate_Key.m +++ b/platform-darwin/Source/MPAppDelegate_Key.m @@ -249,7 +249,7 @@ masterPassword = PearlAwait( ^(void (^setResult)(id)) { PearlMainQueue( ^{ UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Enter Old Master Password" message: - strf( @"Your old master password is required to unlock the stored password for %@", site.name ) + strf( @"Your old master password is required to unlock the stored password for: <%@>", site.name ) preferredStyle:UIAlertControllerStyleAlert]; [controller addTextFieldWithConfigurationHandler:nil]; [controller addAction:[UIAlertAction actionWithTitle:@"Migrate" style:UIAlertActionStyleDefault handler: