I’m attempting to open a modal utilizing Exterior Hyperlink Account on iOS 16.0+ units in my Flutter app. Nevertheless, after I name ExternalLinkAccount.open(), nothing occurs, and I don’t obtain any errors. I’m attempting the next Swift code:
import UIKit
import Flutter
import StoreKit
func openExternalLink() async throws {
if #accessible(iOS 16.0, *) {
if ExternalLinkAccount.canOpen {
attempt await ExternalLinkAccount.open()
} else {
throw NSError(area: "ExternalLinkError", code: -1, userInfo: [NSLocalizedDescriptionKey: "Cannot open external link."])
}
} else {
throw NSError(area: "ExternalLinkError", code: -1, userInfo: [NSLocalizedDescriptionKey: "Unsupported iOS version."])
}
}
@most important
@objc class AppDelegate: FlutterAppDelegate {
override func utility(
_ utility: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
self.window?.makeSecure() // Safe the window to stop delicate knowledge leakage
GeneratedPluginRegistrant.register(with: self)
setupMethodChannel(controller: window?.rootViewController as! FlutterViewController)
return tremendous.utility(utility, didFinishLaunchingWithOptions: launchOptions)
}
}
func setupMethodChannel(controller: FlutterViewController) {
let methodChannel = FlutterMethodChannel(title: "external_link_account", binaryMessenger: controller.binaryMessenger)
methodChannel.setMethodCallHandler { (name: FlutterMethodCall, end result: @escaping FlutterResult) in
if name.technique == "openLinkout" {
if #accessible(iOS 16.0, *) {
Process {
do {
attempt await ExternalLinkAccount.open() // Await right here
end result("Hyperlink opened efficiently!")
} catch {
end result(FlutterError(code: "ERROR", message: "Did not open hyperlink", particulars: nil))
}
}
} else {
end result(FlutterError(code: "OS_TOO_OLD", message: "iOS model too previous", particulars: nil))
}
} else {
end result(FlutterMethodNotImplemented)
}
}
}
I’m attempting to open the exterior hyperlink, however the modal shouldn’t be showing. I made certain the ExternalLinkAccount.open() perform is being referred to as with await, however nonetheless, nothing occurs. Questions: • May there be a problem with calling ExternalLinkAccount.open()? • Is there one thing else I have to do when calling this perform? • What iOS variations ought to I guarantee compatibility with? • Are there any extra sources or examples about this module? Anybody who may assist could be a lot appreciated! Thanks prematurely!