Background mode plugin. Unable to change icon

Hi,

I’m using ionic-native and cordova-plugin-background-mode in my application.

The background mode itself works well but I’m no able to change the icon of the notification.

I have already added the icons in the drawables folders and set the default configuration this way:

this.backgroundMode.setDefaults({
    title: this.translateService.instant("app.background-mode.notification-title"),
    text: this.translateService.instant("app.background-mode.notification-message"),
    color: "000000",
    icon: "icon"
});

Anyway, the notification shows a white square instead of the icon in some devices, for example:

  • Motorola Moto E (Android 5.1)
  • BQ Aquaris M10, see image (Android 6.0)

image

The icon is changed succesfully on:

  • Sony Xperia T3, see image (Android 4.4.4)
  • Samsung Galaxy A3 (Android 6.0.1)

image

Anyone with this same issue?

My system information:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: 1.9.0
ios-sim version: 5.0.11
OS: macOS Sierra
Node Version: v7.1.0
Xcode version: Xcode 8.3.2 Build version 8E2002

1 Like

Related Github issue:

1 Like

@ramon where to trigger the back ground mode,.???

is it in pages like on button click/event…

or else in component.ts…

I am working on Mqtt for IOT application and i need to trigger a notification on mqtt response…in my project

local notification is being used to trigger message,., but it works only in foreground…so i am using background mode plugin but i am confused to use where

My APP is a streaming music player, so, I enable backgroundMode on music start playing and disable it when music stops. Obviouslly, on my player.component.ts.

    private enableBackgroundMode(): void {
        if(this.platform.is('android') && !this.backgroundMode.isEnabled()) {
            this.backgroundMode.enable();
        }
    }

    private disableBackgroundMode(): void {
        if(this.platform.is('android') && this.backgroundMode.isEnabled()) {
            this.backgroundMode.disable();
        }
    }
1 Like

Did you solve it? I have same situation…