Skip to content

Dhruv/migrate to scene delegate - #75

Merged
dporwal-shipit merged 8 commits into
masterfrom
dhruv/migrate-to-sceneDelegate
Jun 2, 2026
Merged

Dhruv/migrate to scene delegate#75
dporwal-shipit merged 8 commits into
masterfrom
dhruv/migrate-to-sceneDelegate

Conversation

@dporwal-shipit

Copy link
Copy Markdown
Collaborator

No description provided.

@isouravganguly isouravganguly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[CRITICAL] smart_investing/pubspec.lockscgateway was downgraded from 7.0.7 to 7.0.5 and scloans from 5.1.3 to 5.1.1. This looks like a branch-sync issue from an older base. These should be reverted to match master before merging.

Reply: This branch has een created from an older version of development.

- Mixpanel-swift (= 5.1.0)
- SCGateway (7.1.7)
- SCGateway-dhruv-migrate-to-sceneDelegate-007ae6e (7.1.6-24-debug)
- scgateway_flutter_plugin (0.0.1):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[CRITICAL] These are debug branch builds (7.1.6-24-debug, 7.1.1-39-debug) pointing to cocoapodspec-internal. This lock file must be regenerated against the final release pod versions before merging to master.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

WIll be updated on release

}

fatalError("SwiftScLoanFlutterPlugin: No root view controller found. Ensure a UIWindow is set up in SceneDelegate or AppDelegate.")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[CRITICAL] fatalError will hard-crash the app if called during edge-case lifecycle moments — cold launch, background transitions, or multi-window on iPad. Change the return type to UIViewController? and let call sites handle nil gracefully instead of crashing unconditionally.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Flutter's method channel dispatch (handle(_:result:)) cannot fire before the FlutterViewController is installed as the root VC — the Flutter engine itself requires a valid window to initialize. By the time any Flutter call arrives, all three fallback chains (foreground scene → any scene → AppDelegate window) already have a rootViewController.

}

fatalError("SwiftScgatewayFlutterPlugin: No root view controller found. Ensure a UIWindow is set up in SceneDelegate or AppDelegate.")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[CRITICAL] Same fatalError crash risk as in ScLoanFlutterPlugin. Return UIViewController? and handle nil at each call site.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Flutter's method channel dispatch (handle(_:result:)) cannot fire before the FlutterViewController is installed as the root VC — the Flutter engine itself requires a valid window to initialize. By the time any Flutter call arrives, all three fallback chains (foreground scene → any scene → AppDelegate window) already have a rootViewController.

SmallcaseGatewaySdk.Result.IMR_SETUP -> {

val transRes = JSONObject(transactionResult.data!!)
transRes.put("success", true)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[CRITICAL] transactionResult.data!! throws NullPointerException if data is null. Use a safe null check and return a structured error to the Flutter layer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It was not a threat as its already in try-catch block.So, no hard crash but still added result.error("TXN_ERROR", e.message ?: "Unknown error in transaction callback", null) logging for local insight

private var notificationObserver: NSObjectProtocol?

var currentViewController: UIViewController {
let foregroundScene = UIApplication.shared.connectedScenes

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[MEDIUM] currentViewController is duplicated verbatim from ScLoanFlutterPlugin. Extract it into a shared internal utility (e.g. FlutterWindowResolver.swift) so any future fix applies to both plugins automatically.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Both ScLoan & ScGateway are published separately.

resDict["signup"] = signup

let jsonData = try! JSONSerialization.data(withJSONObject: resDict, options: [])
let jsonString = String(data: jsonData, encoding: .utf8)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[MEDIUM] try! will crash if resDict contains a non-JSON-serialisable value. Move this inside the existing do/catch block and call result(FlutterError(...)) on failure.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

shifted to try from try!


return
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[MEDIUM] If data is nil or cannot be cast to [String: Any], result() is never called and the Flutter method channel call hangs indefinitely. Add an explicit result(FlutterError(...)) in the else branch.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

result(FlutterError(code: "IMR_SETUP_ERROR", message: error.localizedDescription, details: nil))

capturing for local insights now

@main
@objc class AppDelegate: FlutterAppDelegate {
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
override func application(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[MEDIUM] FlutterImplicitEngineDelegate and FlutterImplicitEngineBridge are not part of the public Flutter Engine API. This is fragile and may break silently on Flutter upgrades. Confirm this is a sanctioned integration path before merging.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

SmartInvesting level issue: conforming to FlutterImplicitEngineDelegate is a hard requirement to which all SceneDelegate Migrated Apps should adhere to.

# Uncomment this line to define a global platform for your project
platform :ios, '14.0'
platform :ios, '15.0'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[MEDIUM] Bumping to iOS 15 drops support for iOS 14 users. The currentViewController logic already has #available(iOS 15.0, *) guards with iOS 13-compatible fallbacks, so the 15.0 floor is not strictly required. Revert to 14.0 unless there are other hard dependencies on iOS 15+.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

SmartInvesting level issue

@dporwal-shipit
dporwal-shipit merged commit b77e38d into master Jun 2, 2026
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.

2 participants