0
I have a background problem with Ionic, follow settings:
The background plugin is Backgroundmode.
"@ionic-native/background-mode": "^5.31.1",
"cordova-plugin-background-mode": "^0.7.3",
When I’m with the app in the background, local notifications arrive, but once I close the app effectively, notifications stop coming.
Can you help me with this? I’m using the wrong plugin?
Code:
app.componentts.
import { Component } from '@angular/core';
import { BackgroundMode } from '@ionic-native/background-mode/ngx';
import { Platform } from '@ionic/angular';
import { Plugins } from '@capacitor/core';
const { LocalNotifications } = Plugins;
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
})
export class AppComponent {
constructor(private platform: Platform, private backgroundMode: BackgroundMode)
{
this.platform.ready().then(() => {
this.backgroundMode.on('activate').subscribe(() => {
for (let i = 0; i < 999999999; i++)
{
LocalNotifications.schedule({
notifications: [
{
title: "Title",
body: "Body",
id: i + 1,
}]
})
}
});
this.backgroundMode.enable();
});
}
}
Edit
On Android, I was able to solve with this code block on Androidmanifest.xml, after generating the build:
Tag <activity>
include: android:excludeFromRecents="true"
On iOS the problem persists...