启动InAppBrowser时,ParseLiveQuery停止工作

时间:2017-06-22 04:23:37

标签: ionic-framework parse-platform ionic2 parse-server inappbrowser

即使启动了InAppBrowser,我也希望使用ParseLiveQuery持续监控事件。但我不能。

我注意到,当启动InAppBrowser时,Parse服务器中的所有事件都会暂停/暂停。

以下是演示此问题的简化代码:

export interface PageInterface {
  title: string;
  name: string;
  component: any;
  icon: string;
  logsOut?: boolean;
  index?: number;
  tabName?: string;
  tabComponent?: any;
}    
@Component({
  templateUrl: 'app.template.html'
})
export class ConferenceApp {
  @ViewChild(Nav) nav: Nav;
  appPages: PageInterface[] = [...];
  loggedInPages: PageInterface[] = [...];
  rootPage: any;
  browser: any;

  constructor(
    public events: Events,
    public userData: UserData,
    public menu: MenuController,
    public platform: Platform,
    public confData: ConferenceData,
    public parseData: ParseData,
    public storage: Storage,
    public splashScreen: SplashScreen,
    private iab: InAppBrowser
  ) {

    this.rootPage = TabsPage;
    this.platformReady();

  }

  listenToParse(){
    this.parseData.subscribe().then(
      (subscription)=> {
        subscription.on('open', () => {
          console.log('subscription opened');
        });
        subscription.on('update', (object:any) => {
          console.log('object updated');
        });
      },
      (error)=>{
        console.log(error);
      }
    );
  }

  openPage(page: PageInterface) {
    ...
  }


  enableMenu(loggedIn: boolean) {
    this.menu.enable(loggedIn, 'loggedInMenu');
    this.menu.enable(!loggedIn, 'loggedOutMenu');
  }

  platformReady() {
    // Call any initial plugins when ready
    this.platform.ready().then(() => {
      this.splashScreen.hide();

      this.listenToParse();

      setTimeout(() => {
        console.log("time out fired, launch iab!");
        this.browser = this.iab.create("https://www.google.com","_blank");
      },60000);

    });
  }

  isActive(page: PageInterface) {
    ...
  }
}

在上面的演示代码中,我们监听来自Parse服务器的数据更改。它一直有效,直到60秒后启动InAppBrowser。这是日志输出:

2017-06-27 16:36:56.522724+0800 My App[2006:312223] subscription opened
2017-06-27 16:37:24.459593+0800 My App[2006:312223] object updated
2017-06-27 16:37:26.982129+0800 My App[2006:312223] object updated
2017-06-27 16:37:30.032242+0800 My App[2006:312223] object updated
2017-06-27 16:37:32.757926+0800 My App[2006:312223] object updated
2017-06-27 16:37:34.658421+0800 My App[2006:312223] object updated
2017-06-27 16:37:36.531520+0800 My App[2006:312223] object updated
2017-06-27 16:37:38.509784+0800 My App[2006:312223] object updated
2017-06-27 16:37:41.072448+0800 My App[2006:312223] object updated
2017-06-27 16:37:42.989296+0800 My App[2006:312223] object updated
2017-06-27 16:37:44.706035+0800 My App[2006:312223] object updated
2017-06-27 16:37:46.826566+0800 My App[2006:312223] object updated
2017-06-27 16:37:49.347574+0800 My App[2006:312223] object updated
2017-06-27 16:37:51.268267+0800 My App[2006:312223] object updated
2017-06-27 16:37:53.182077+0800 My App[2006:312223] time out fired, launch iab!
2017-06-27 16:37:53.621465+0800 My App[2006:312223] THREAD WARNING: ['InAppBrowser'] took '420.479980' ms. Plugin should use a background thread.
2017-06-27 16:37:53.623936+0800 My App[2006:312223] object updated
2017-06-27 16:37:53.862435+0800 My App[2006:312379] libMobileGestalt MobileGestaltSupport.m:153: pid 2006 (My App) does not have sandbox access for frZQaeyWLUvLjeuEK43hmg and IS NOT appropriately entitled
2017-06-27 16:37:53.862619+0800 My App[2006:312379] libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see <rdar://problem/11744455>)
2017-06-27 16:37:57.409094+0800 My App[2006:312223] object updated
2017-06-27 16:37:59.316170+0800 My App[2006:312712] WF: === Starting WebFilter logging for process My App
2017-06-27 16:37:59.316283+0800 My App[2006:312712] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2017-06-27 16:37:59.316718+0800 My App[2006:312712] WF: _WebFilterIsActive returning: NO

//InAppBrowser launched. 

InAppBrowser启动后不再有对象更新事件。为什么?

我的依赖项:

  "dependencies": {
    "@angular/common": "4.1.2",
    "@angular/compiler": "4.1.2",
    "@angular/compiler-cli": "4.1.2",
    "@angular/core": "4.1.2",
    "@angular/forms": "4.1.2",
    "@angular/http": "4.1.2",
    "@angular/platform-browser": "4.1.2",
    "@angular/platform-browser-dynamic": "4.1.2",
    "@ionic-native/core": "3.10.2",
    "@ionic-native/in-app-browser": "3.10.2",
    "@ionic-native/splash-screen": "3.10.2",
    "@ionic-native/status-bar": "3.10.2",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.3.0",
    "ionicons": "3.0.0",
    "parse": "1.9.2",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.8.11"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.7",
    "@ionic/cli-plugin-ionic-angular": "1.2.0",
    "typescript": "2.3.3"
  }

0 个答案:

没有答案