alibaba / flutter_boost

FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts
https://github.com/alibaba/flutter_boost
MIT License
6.98k stars 1.23k forks source link

Flutter返回IOS,onPageFinished没有回调 #926

Open ethi1989 opened 3 years ago

ethi1989 commented 3 years ago

Steps to Reproduce

我使用的是官方提供的example_swift,进行原生跳转flutter的试验,从Flutter跳转回来后,并未回调onPageFinished

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}

@IBAction func onClickPushFlutterPage(_ sender: UIButton, forEvent event: UIEvent){
    FlutterBoostPlugin.open("first", urlParams:[kPageCallBackId:"MycallbackId#1"], exts: ["animated":true], onPageFinished: { (_ result:Any?) in
        print(String(format:"call me when page finished, and your result is:%@", result as! CVarArg));
    }) { (f:Bool) in
        print(String(format:"page is opened"));
    }
}
@IBAction func onClickPresentFlutterPage(_ sender: UIButton, forEvent event: UIEvent){
    FlutterBoostPlugin.present("second", urlParams:[kPageCallBackId:"MycallbackId#2"], exts: ["animated":true], onPageFinished: { (_ result:Any?) in
        print(String(format:"call me when page finished, and your result is:%@", result as! CVarArg));
    }) { (f:Bool) in
        print(String(format:"page is presented"));
    }
}

}

Flutter Boost Version 1.17.1,Flutter VERSION: 1.22.1 Flutter Target Platform: iOS 10 Target OS version/browser: IOS 13.6 Devices: IPHONE 7

Logs

Flutter Boost Version 1.17.1,Flutter VERSION: 1.22.1 Flutter Target Platform: iOS 10 Target OS version/browser: IOS 13.6 Devices: IPHONE 17

TopSkySir commented 3 years ago

same +

nightfallsad commented 3 years ago

Steps to Reproduce

我使用的是官方提供的example_swift,进行原生跳转flutter的试验,从Flutter跳转回来后,并未回调onPageFinished

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}

@IBAction func onClickPushFlutterPage(_ sender: UIButton, forEvent event: UIEvent){
    FlutterBoostPlugin.open("first", urlParams:[kPageCallBackId:"MycallbackId#1"], exts: ["animated":true], onPageFinished: { (_ result:Any?) in
        print(String(format:"call me when page finished, and your result is:%@", result as! CVarArg));
    }) { (f:Bool) in
        print(String(format:"page is opened"));
    }
}
@IBAction func onClickPresentFlutterPage(_ sender: UIButton, forEvent event: UIEvent){
    FlutterBoostPlugin.present("second", urlParams:[kPageCallBackId:"MycallbackId#2"], exts: ["animated":true], onPageFinished: { (_ result:Any?) in
        print(String(format:"call me when page finished, and your result is:%@", result as! CVarArg));
    }) { (f:Bool) in
        print(String(format:"page is presented"));
    }
}

}

Flutter Boost Version 1.17.1,Flutter VERSION: 1.22.1 Flutter Target Platform: iOS 10 Target OS version/browser: IOS 13.6 Devices: IPHONE 7

Logs

Flutter Boost Version 1.17.1,Flutter VERSION: 1.22.1 Flutter Target Platform: iOS 10 Target OS version/browser: IOS 13.6 Devices: IPHONE 17

present吧?试了下open回调了

MMMMiller commented 11 months ago

找到原因了, example没在delegate里记录回调。解决方法如下,供参考: 在pushFlutterRoute方法中记录onPageFinished,例如resultTable[options.pageName] = options.onPageFinished; 然后在popRoute方法中触发onPageFinished,if let onPageFinished = resultTable[options.pageName] { onPageFinished(options.arguments) resultTable.removeValue(forKey: options.pageName) }