Dhruv/migrate to scene delegate - #75
Conversation
- Handle IMR_SETUP transaction result on Android - Add IMR_SETUP case to iOS IntentType enum and handle response - Expose IMR_SETUP constant in Dart ScgatewayIntent class - Bump Android SDK to 6.1.0, iOS SCGateway to 7.2.0
…currency errors
There was a problem hiding this comment.
[CRITICAL] smart_investing/pubspec.lock — scgateway 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): |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
WIll be updated on release
| } | ||
|
|
||
| fatalError("SwiftScLoanFlutterPlugin: No root view controller found. Ensure a UIWindow is set up in SceneDelegate or AppDelegate.") | ||
| } |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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.") | ||
| } |
There was a problem hiding this comment.
[CRITICAL] Same fatalError crash risk as in ScLoanFlutterPlugin. Return UIViewController? and handle nil at each call site.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
[CRITICAL] transactionResult.data!! throws NullPointerException if data is null. Use a safe null check and return a structured error to the Flutter layer.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
Both ScLoan & ScGateway are published separately.
| resDict["signup"] = signup | ||
|
|
||
| let jsonData = try! JSONSerialization.data(withJSONObject: resDict, options: []) | ||
| let jsonString = String(data: jsonData, encoding: .utf8) |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
shifted to try from try!
|
|
||
| return | ||
| } | ||
|
|
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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' | ||
|
|
There was a problem hiding this comment.
[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+.
There was a problem hiding this comment.
SmartInvesting level issue
No description provided.