首页 > 解决方案 > 在应用简历上显示主要内容之前打开模式

问题描述

在我的 ionic 应用程序中,当应用程序恢复时,我会显示锁屏模式。我只想在用户成功输入正确的 pin 时才显示应用程序内容,否则应用程序正在最小化。我的问题是查看模式的延迟。一段时间后显示模态,在那个时候应用程序已经加载并且应用程序的所有内容在一段时间内都是可见的,这是我不想要的。在启动应用程序的情况下,我通过实现APP_INITIALIZE首先查看模式然后加载应用程序的主要内容的功能成功地解决了这个问题。但我无法在暂停/恢复方法中实现相同的功能。这是我的代码:

app.component.ts

initializeApp() {
    this.platform.pause.subscribe(async () => {
      const time = (await Storage.get({key: 'pauseTimeout'})).value;
      this.pauseTimeout = Number(time + '000');
      this.timeout = false;
      this.timeoutObj = setTimeout(() => {
        this.timeout = true;
      }, this.pauseTimeout);
    });
    this.platform.resume.subscribe(() => {
      clearTimeout(this.timeoutObj);
      if (this.timeout) {
        this.userService.loggedIn_()
          .then(async loggedIn => {
            if (loggedIn) {
              const cred = await this.userService.getCredentials_();
              if (cred && cred.passcode) {
                const passModal = await this.modalController.create({
                  component: PasscodePage,
                  componentProps: { passMethod: 'accessApp' }
                });
                await passModal.present();
              }
            }
          });
      }
    });

pauseTimeout基本上,如果达到,我会显示一个模态。但是由于验证已经花费了一些时间loggedIn,因此应用程序的主要内容已经在这段时间内加载了。有没有办法在模态解雇后加载该内容?

标签: angularionic-framework

解决方案


推荐阅读