0

does anyone know how to disable the back swipe after navigating to a new page?

I read this: http://docs.nativescript.org/angular/core-concepts/angular-navigation#clearing-page-navigation-history

Clearing Page Navigation History In NativeScript's page navigation, you have the option to navigate to another page and clear the page navigation history. This means that the user will not be able to go back using the back button (or swipe back in iOS). This is useful in scenarios where you have a login page and you don't want users to be able go go back to it once logged in. But I want to go back to login page when the user clicked logout.

I have 2 pages, LoginPage and FirstPage. Im using RouterExtensions. so this.nav.navigate([“/firstPage"], { clearHistory: true}); this works. On second page i have a button that goes to this.nav.navigate([“/”]) (so back to the login page). But I get

Aug 11 19:30:26 antons-MBP appname[62814]: CONSOLE ERROR file:///app/tns_modules/zone.js/dist/zone-node.js:421:23: Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'cacheItem.reusedRoute')

2 Answers 2

0

I tested clearHistory while navigating to new page and it seems that everything work as expected. Could you verify, whether you are using latest CLI and modules. You could find instructions here, where have been described how to upgrade to latest NativeScript. In regard to that it you need to upgrade the tns-core-modules and nativescript-angular in exciting project you could follow the below described instructions.

  1. tns plugin remove tns-core-modules
  2. tns plugin add [email protected]
  3. tns plugin remove nativescript-angular
  4. tns plugin add [email protected]

You could also review my sample app here, how to use clearHistory in NativeScript Angular.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi Nik, I have updated my project and also cloned your project from gitHub. It works now. BUT. Pressed "GO TO SECOND" => swipe from left to right (edge of the screen) =>tap "GO TO FIRST". Result, nothing appears on the screen and no error is thrown
I will review this scenario and will write you back when I have possible solution.
Thank you. After reading a bunch of articles on how to do it in Objective-C, I modified the page.ios.js in "ui/page". I added this.navigationController.interactivePopGestureRecognizer.enabled = false (Line 172) and it solved the problem. Of course, this is only a partial solution since I modified a library and now it affects all pages. Hope this helps.
Hi artonio, I opened new issue in nativescript-angular repo, where the developers of NativeScript will review and fix the problem -github.com/NativeScript/nativescript-angular/issues/400 .
0

I was able to disable the swipe gesture per page by inserting the following code

constructor(private nav: RouterExtensions) {

    this.nav.frame.ios.controller.interactivePopGestureRecognizer.enabled = false;

  }

This way I don't have to modify the library, but the downside is that I have to re-enable "interactivePopGestureRecognizer" on every page that i want to the back swipe to work on.

1 Comment

not the angular routerextensions shows error on frame part, any info?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.