SubscribeWithPriority unsubscription in app.component.ts

The thing is I found a way to unsubscribe a normal subscription in NgOnDestroy but it is not working with subscribeWithPriority.

this.platform.backButton
.pipe(takeUntil(this.ngDestroyed$))
.subscribeWithPriority(0, async () => {}

It returns an error:
Property 'subscribeWithPriority' does not exist on type 'Observable<BackButtonEventDetail>'

I think this is one of those (hopefully) rare cases where your best option is to pull rank on the type system with a type assertion:

(this.platform.backButton.pipe(takeUntil(this.ngDestroyed$)) as BackButtonEmitter)
   .subscribeWithPriority(0, () => {});

The pipe call unfortunately “washes” the more specific type of backButton (which contains the method you want) down to an Observable (which doesn’t, hence your error).

Please, could you put here the complete code for this issue because I have a problem like that. In my case when I tap ion-back-button doesn’t fire the function.
I need to be aware when the user exit by back button
Thx