From 0c7a1d8282ea3c1fdb556dfceb5d27b128e5b472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20L=C3=A9vy?= Date: Wed, 19 Dec 2018 12:56:54 +0100 Subject: [PATCH] Now present a viewController from the topmost viewController --- ios/RNSumUp.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ios/RNSumUp.m b/ios/RNSumUp.m index 70b9f87..22d1030 100644 --- a/ios/RNSumUp.m +++ b/ios/RNSumUp.m @@ -60,6 +60,9 @@ - (NSDictionary *)constantsToExport { dispatch_sync(dispatch_get_main_queue(), ^{ UIViewController *rootViewController = UIApplication.sharedApplication.delegate.window.rootViewController; + while (rootViewController.presentedViewController != nil) { + rootViewController = rootViewController.presentedViewController; + } [SMPSumUpSDK presentLoginFromViewController:rootViewController animated:YES completionBlock:^(BOOL success, NSError *error) { if (error) { [rootViewController dismissViewControllerAnimated:YES completion:nil]; @@ -68,8 +71,7 @@ - (NSDictionary *)constantsToExport SMPMerchant *merchantInfo = [SMPSumUpSDK currentMerchant]; NSString *merchantCode = [merchantInfo merchantCode]; NSString *currencyCode = [merchantInfo currencyCode]; - if (merchantCode && currencyCode){ - RCTLogInfo(@"WavyError: success2"); + if (merchantCode && currencyCode) { return resolve(@{@"success": @(success), @"userAdditionalInfo": @{ @"merchantCode": merchantCode, @"currencyCode": currencyCode }}); } return resolve(@{@"success": @(success) }); @@ -132,6 +134,9 @@ - (NSDictionary *)constantsToExport checkoutRequest.skipScreenOptions = skipScreen; dispatch_sync(dispatch_get_main_queue(), ^{ UIViewController *rootViewController = UIApplication.sharedApplication.delegate.window.rootViewController; + while (rootViewController.presentedViewController != nil) { + rootViewController = rootViewController.presentedViewController; + } [SMPSumUpSDK checkoutWithRequest:checkoutRequest fromViewController:rootViewController completion:^(SMPCheckoutResult *result, NSError *error) { @@ -157,6 +162,9 @@ - (NSDictionary *)constantsToExport { dispatch_sync(dispatch_get_main_queue(), ^{ UIViewController *rootViewController = UIApplication.sharedApplication.delegate.window.rootViewController; + while (rootViewController.presentedViewController != nil) { + rootViewController = rootViewController.presentedViewController; + } [SMPSumUpSDK presentCheckoutPreferencesFromViewController:rootViewController animated:YES completion:^(BOOL success, NSError * _Nullable error) {