Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work on a presented ViewController (Modal) #168

Merged
merged 4 commits into from
Dec 14, 2018

Conversation

nhnam
Copy link
Contributor

@nhnam nhnam commented Dec 12, 2018

Fix the way we show accountkit navigation controller:
Old way's issues: If we call AccountKit from a presentedViewController (Modal), it won't work. Error log:
Warning: Attempt to present <AKFNavigationController: 0x107000000> on <UIViewController: 0x1061398d0> which is already presenting <RCTModalHostViewController: 0x1060d0bc0>
Seems like the App's current ViewController is busy presenting the modal which wants to present AccountKit.

Fix the way we show accountkit navigation controller:
Old way's issues: If we call AccountKit from a presentedViewController (Modal), it won't work. Error log:
Warning: Attempt to present <AKFNavigationController: 0x107000000>  on <UIViewController: 0x1061398d0> which is already presenting <RCTModalHostViewController: 0x1060d0bc0>
Seems like the App's current ViewController is busy presenting the modal which wants to present AccountKit.
@@ -58,7 +58,7 @@ - (void)loginWithPhone: (RCTPromiseResolveBlock)resolve
UIViewController<AKFViewController> *viewController = [_accountKit viewControllerForPhoneLoginWithPhoneNumber:prefillPhoneNumber state:inputState];
[self _prepareLoginViewController:viewController];
UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
[rootViewController presentViewController:viewController animated:YES completion:NULL];
[rootViewController showViewController:viewController sender:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if this can be configurable. I think two options here:

  • Adding a new field to the RNAccountKit.configure argument:
RNAccountKit.configure({
  ...
  viewControllerMode: 'show'|'present' // for iOS only, 'present' by default
})
  • Changing the signature of loginWithPhone and loginWithEmail only if we can keep the method backward compatible (It could be more difficult to implement.
RNAccountKit.loginWithEmail({ 
  viewControllerMode: 'show'|'present' // 'present' by default 
})

RNAccountKit.loginWithPhone({ 
  viewControllerMode: 'show'|'present' // 'present' by default 
})
``

Adding @gaguirre to the discussion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your guide, I will try then back to you 👍

@nhnam
Copy link
Contributor Author

nhnam commented Dec 13, 2018

I've updated my changes to support more options while configuring RNAccountKit. Could you please review it and give me some feedback?
Thanks
@gaguirre

@@ -29,6 +29,7 @@ class RNAccountKit {
readPhoneStateEnabled: true,
receiveSMS: true,
theme: {},
viewControllerMode: 'present' // for iOS only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have this option included in the Readme

Also you can include a note maybe with the link of the issue it solves

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated README, could you please take a look?

[rootViewController showViewController:viewController sender:nil];

if([_viewControllerMode isEqualToString:@"present"]) {
[rootViewController showDetailViewController:viewController sender:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be this line as it was before? is there a reason to change that?

[rootViewController presentViewController:viewController animated:YES completion:NULL];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah, I reverted it to the old way.

[rootViewController showViewController:viewController sender:nil];

if([_viewControllerMode isEqualToString:@"present"]) {
[rootViewController showDetailViewController:viewController sender:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

@jpgarcia jpgarcia merged commit 619faf0 into Nubescope:master Dec 14, 2018
@jpgarcia
Copy link
Contributor

Guys, I've just published v1.0.1. Thank you for your contribution!

@nhnam
Copy link
Contributor Author

nhnam commented Dec 14, 2018

Thanks @jpgarcia !

@danhnguyeen
Copy link

Hi @jpgarcia ,
this option still didn't work for me. When I call RNAccountKit in the Modal,

RNAccountKit.loginWithPhone({ 
  viewControllerMode: 'show' 
})

there is nothing happen :(

"react-native": "0.57.8",
"react-native-facebook-account-kit": "^1.2.0"

@nhnam
Copy link
Contributor Author

nhnam commented Jul 4, 2019

@danhnguyeen
What is your problem? Could you explain more?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants