I am facing strange issue in ionic 3 pause and resume events, whenever I paused the application, events are calling multiple times(once 2, once 3 etc). Here is the code
I have tried by placing the same code in ionViewDidLoad, Constructor, ionViewWillEnter still facing same issue. Please anybody help me to get resolve this. I’m calling one service once the app is resumed but now its calling multiple times.Thanks!!
In this example I presume that you specify resumeListener in the constructor of the class right?
so something like this:
import { Subscription} from 'rxjs/Subscription';
export class MyPage{
public resumeListener: Subscription = Subscription;
constructor(public platform: Platform){
this.resumeListener = new Subscription();
}
....
}
Is that correct? I am really struggling to get this to function as I desire. I want code to execute when the application has been moved to the background by the user but not by the app, for instance going to a camera to scan a barcode and then returning to the page to process it. In this instance, with the camera, the whole code is re-executed.
If you need to keep listening but only execute certain logic, you can simply set a toggle variable which will be switched on/off by resume and pause handlers
File: app.components.ts
export class MyApp {
…
public resumed:boolean = false;
…
constructor(
…
this.platform.resume.subscribe((res) => {
if(this.resumed == false){