Can you cancel a navigation within the NavController?

Authentication is tricky for me because at any point, due to third parties involved, the server can decline my request and I’d have to get a new token and authenticate again (don’t ask, it’s not my server). Preferably I would have done this check using Angular 2 CanActivate route guard, but seeing how Ionic 2 doesn’t quite support this yet, I’m thinking of just subscribing to the NavController viewWillEnter event. Here’s what I have so far.

import { Service } from './services/oauth';
    templateUrl: 'build/app.html'
export class App {
    @ViewChild(Nav) nav: Nav;
    rootPage: any = InboxPage;

    constructor(public platform: Platform) {

    init() {
        this.platform.ready().then(() => {

            this.nav.viewWillEnter.subscribe(data => {
                console.log('viewWillEnter', data);

                if (!Service.isAuthenticated && !== "LoginPage") {
                    debugger; //now what? How do you cancel? return false?


when are you getting authenticated in this code ? Anyways, how about ?

rootPage: any;

init() {
  if (!Service.isAuthenticated) { 
     rootPage = LoginPage;
  else {
     rootPage = InboxPage;

does that work ? Or am I missing the point ?

I’m porting an Angular 1.3 app, and the logic for authentication is handled as a resolve function for all the routes in the router config.

What you have can work initially. The challenge I have is that the user can lose their authentication while they’re using the app. I need to be able to detect when that happens, re-authenticate the user, and the re-submit their failed requests.

I’m on the same issue. Have you resolved the problem?

Not yet, I was looking at the source code, and it appears that the NavController just emits the observable. No code to handle a return value or preventDefault() call. Seems like they would need to implement this.

So it’s possible to create some new level of abstraction which will manage ability of going to some page