Hardware Back button , subscribeWithPriority returning void for processNexthandler

When trying to call multiple handlers with same priority using processNextHandler, returning the void error stated below

Argument of type '(processNextHandler: any) => void' is not assignable to parameter of type '() => void | Promise<any>'

any fix for this?

Please post the code you have written that triggers this error.

Please check below code

both these handlers are in different files and i want to run one after the other.


import { Platform } from "@ionic/angular";

this.platform.backButton.subscribeWithPriority(5, ( ) => {
			if (){
                               // do something
                          }

		});


this.platform.backButton.subscribeWithPriority(10, (processNextHandler) => {
			if (){
                               // do something
                          }

			processNextHandler();
		});

Any chance you’re using a framework version older than 5.1.0? That’s when the feature you’re trying to use was added.

You are right, the ionic framework version is 4.11.5 and ionic cli version is 5.4.16.
Thanks for checking.

Hi, I was post a question with the same issue, I see the same message for processNextHandler, below the package. Do I have to update?

image
Ionic:

Ionic CLI : 5.4.16
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.1002.0
@angular-devkit/schematics : 10.1.7
@angular/cli : 10.0.1
@ionic/angular-toolkit : 2.3.3

Cordova:

Cordova CLI : not installed
Cordova Platforms : 6.0.0, android 8.1.0, browser, ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 7 other plugins)

Utility:

cordova-res : not installed
native-run : not installed

System:

NodeJS : v14.15.0 (C:\Program Files\nodejs\node.exe)
npm : 6.14.8
OS : Windows 10

Yes , update ionic framework to version 5 and processNextHandler is accessible.

Looks that way to me.

Thanks for your reply…
I tried many ways, no success

npm update -g ionic
npm uninstall -g ionic 
npm install -g ionic
npm update -g @ionic/angular

Sorry, first PWA… could you suggest how to update?

All the things you mentioned only deal with the CLI. You need to update the framework in your project. I usually just manually edit package.json and rerun npm i.

Thanks my friend… I just updated the version… Now I will work on this issue.
image

Hi dear… could you give one more help by now? IĀ“m stuck trying to work hardware back button on PWA. According to ionic documentation there is no support for that. Maybe is there another solution? I tried the code below, just to alert and check button pressed is handled, but not working.

directly on feed.page.ts, last page before leaving the APP.

this._Platform.backButton.subscribeWithPriority(666666, (processNextHandler) => {
if (window.confirm(ā€œDo you want to exit APPā€)) {
alert(ā€˜OK’);
}
});

Thanks in advanced

1 Like

Thank you :slight_smile: