Fix view controller presentation by using displayController parameter#463
Open
sriharsha-y wants to merge 1 commit intorazorpay:masterfrom
Open
Fix view controller presentation by using displayController parameter#463sriharsha-y wants to merge 1 commit intorazorpay:masterfrom
sriharsha-y wants to merge 1 commit intorazorpay:masterfrom
Conversation
Fixes razorpay#461 Problem: The Flutter plugin was calling razorpay.open(options) without the displayController parameter, forcing the native Razorpay SDK to use the root view controller for presentation. This fails when the root VC has already presented another view controller, causing the error: "Attempt to present on <UIViewController> which is already presenting" This occurs in any scenario where modal presentations exist in the view hierarchy (e.g., mixed React Native + Flutter projects, or apps with complex navigation patterns). Solution: The native Razorpay iOS SDK (razorpay-pod) supports an optional displayController parameter in its open method to specify which view controller should present the payment interface. This fix leverages that capability: - Added presentedViewControllerFromRoot() to find the topmost presented view controller in the hierarchy - Modified razorpay.open() call to pass this controller via displayController parameter when available - Falls back to original call without displayController if no presented VC exists This properly utilizes the native SDK's intended flexibility and fixes presentation failures in complex view hierarchies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #461
Problem:
The Flutter plugin was calling razorpay.open(options) without the displayController parameter, forcing the native Razorpay SDK to use the root view controller for presentation. This fails when the root VC has already presented another view controller, causing the error: "Attempt to present on which is already presenting"
This occurs in any scenario where modal presentations exist in the view hierarchy (e.g., mixed React Native + Flutter projects, or apps with complex navigation patterns).
Solution:
The native Razorpay iOS SDK (razorpay-pod) supports an optional displayController parameter in its open method to specify which view controller should present the payment interface. This fix leverages that capability:
This properly utilizes the native SDK's intended flexibility and fixes presentation failures in complex view hierarchies.