简体   繁体   中英

ionic4 / angular7 - How should one use the navigation API on unexpected BLE interrupts?

The code in development is running on both Android and iOS, the frameworks in use are Angular7 and ionic4 as well as the cordova BLE plugin.

After an unexpected connection failure, the app should navigate back to the root URL / home screen, which it does. But afterwards it is not possible to navigate away from the home screen and the application is stuck.

I've so far ascertained that a navigation event is indeed fired and that the underlying BLE plugin does still work and establish a new connection when trying to reconnect.

According to the Google Chrome developer tools, the DOM is clear of any remaining pages, as would be expected.

Also, I've ascertained that any services holding a global state are completely reset.

I've tried updating angular and ionic to the latest version, but it does not make a difference.

This code snippet is called as a callback to the (click)-Event from some s

this.communicatorService.connect(device).subscribe(
            peripheral => {
                console.debug('CONNECTED');
                this.zone.run(() => {
                    this.navCtrl.navigateForward('/connected').then(
                        _ => console.debug('NAVIGATED')
                    );
                });
            },
            error => {
                console.error(error);
                this.resetState();
                this.zone.run(() => {
                    this.navCtrl.navigateBack('/').then(
                        _ => console.debug('NAVIGATED BACK')
                    )
                });
            }
        );

What I expect would be to read CONNECTED and NAVIGATED on the console and then witness a page transition.

This is only the case before the app experiences an unexpected BLE connection loss.

After a connection loss I can read 'NAVIGATED BACK' on the console. When trying to reconnect to the BLE device, the code-snippet is executed and I can read CONNECTED and NAVIGATED, but no page transition occurs.

Am I using the navigation API correctly in this case?

Found the error. I had a blocking statement in a controller's ngOnDestroy-method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM