Skip to content

Ionic background mode doesn't work well in my ionic application #10

@n1705771

Description

@n1705771

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions