skip to Main Content

hi there i want to build a lock screen for my app which lock my app from working till user enter a password

the problem is when i navigate to the lock screen by this code user can push back button on his phone and return to the last page before lock

import { Component } from '@angular/core';
import { Router } from '@angular/router';



this.router.navigate(['lock']);

just link telegram local lock work

enter image description here

enter image description here

2

Answers


  1. Can enable and disable hardware back button for that page

    hardwareDetect: Subscription;
    
    constructor(){
      this.hardwareDetect = this.platform.backButton.subscribeWithPriority(99, () => {
    
            });
    }
    
    
      ionViewDidLeave() {
         this.hardwareDetect.unsubscribe();
      }
    
    Login or Signup to reply.
  2. Make your lock screen as model.
    And in this was modal will not close and will keep up till the user enter his password, and in all apps if you recongnize (whatsapp) and other apps , they use modals to set lock and not normal pages , since they are more secured .
    Second and thats the terible part that sunce it is js/html app, users can inspect its url and change it to another page and thus lock will be away so in this way either you need to pass lock to open in a resolver, or to make it as modal and thus when url change or backbutton triggered the oage will change but modal will keep opened.
    And though you can put a subscribe for backbutton in modal to disable app backbutton action for app while modal is open.

    Way to achieve:

    The first thing is that you have the page so no need to create a new page.
    Second declar modal in constructor and import it as made in the link below.
    https://ionicframework.com/docs/v4/api/modal

    And in check of pass is wrong or true, if pass is true then this.modal.dismiss().
    And thats every thing. Its too much easy.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search