Skip to content

Commit

Permalink
Now present a viewController from the topmost viewController
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlevy0 committed Dec 19, 2018
1 parent b53fce6 commit 0c7a1d8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ios/RNSumUp.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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) });
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 0c7a1d8

Please sign in to comment.