This.platform.platforms() gets stuck with iphone


#1

Hi,
I’m using “ionic view” app to test my developing app.
The problem I’m running into is that this.platform.platforms() always gets stuck with iphone. (iOS 11.2.5)
I created a new app with template of sidemenu and edited the home.ts to as below

import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
//  obj: any;
  constructor(public navCtrl: NavController, public platform: Platform) {
	  let obj = this.platform;
	setTimeout(function(){alert(obj.platforms());},5000);
  }

}

I tested the codes on ionic view with android mobile without problem but iphone would get stuck as long as there are codes with “this.platform”. ex. alert(this.platform.is(‘ios’)) will also get stuck.

My public channel id is d6494198
I wonder if you guys have no problems under this scenario or is there something wrong by me?
Thank you very much.


#2

The app runs in my ionic view and then becomes unresponsive for clicks on menu toggle

Post your code, ideally using stackblitz


#3

Thanks for testing. Did you test the app with iphone?
I can execute the app without problem. The alert will pop up.
But with iphone, as long as it runs into “this.platform”, it will become unresponsive.
I guess there is something wrong when this.platform is executed on ios.
However, I can’t make sure if other developers are also running into this problem.
Could you please create a arbitrary app and import Platform as my codes post and then add alert(obj.platforms()); to see if the alert pops up correct.
Many thanks!


#4

Before I do so, plse try yourselft without using function but fat arrow in your setTimeout

That is for sure csusing the pain as it loses scope because of that hence the method call is invalid

Didnt see that before.

Using ios indeed

edit: proper code:

import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
//  obj: any;
  constructor(public navCtrl: NavController, public platform: Platform) {
//	  let obj = this.platform;
//	setTimeout(function(){alert(obj.platforms());},5000);
  }

  ionViewDidEnter() {

      this.platform.ready()
           .then(()=>{
                   alert(JSON.stringify(this.platform.platforms(),null,2))
        })
     }
}