-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I want my ionic app can continue send message to the server even though the phone screen turn off or enter the background mode. To achieve this, I apply ionic native background mode as:
//background mode enable
this.backgroundMode.enable();
//When background mode is activated
this.backgroundMode.on("activate").subscribe(()=>{
console.log("activate background mode");
//clear intervalId
clearInterval(this.intervalId);
//set interval for sending message every 10 seconds
this.intervalId = setInterval(() => {this.sendMessage()}, 10000);
});
clearInterval(this.intervalId);
this.intervalId = setInterval(() => {this.sendMessage()}, 10000);
When I run the program in my Android phone, it just works properly for exact 5 minutes in background mode, then stop sending the messages.
Can you explain why background mode doesn't works well? How can I solve this problem?
Metadata
Metadata
Assignees
Labels
No labels