cordova-plugin-background-mode
cordova-plugin-background-mode copied to clipboard
Changing the notification info not working
I am writing this:
cordova.plugins.backgroundMode.setDefaults({
title: "helo",
text: "Text",
icon: 'icon',
color: "F14F4D",
resume: true
})
But when minize the app, I see the default OS notification info and when click on it it moves to app settings instead of just open it.
Android any device. Plugin version: 0.7.3
I second that. Is there something wrong with the plugin?
Same here.... the notification parameters couldn't be changed even if I edited the Java code... What the heck?? :-O
FOUND the solution: you have to define the icon name, which you first should create (add new image asset in Android Studio). When I don't define the icon, the notification will be generated with the default data....
FOUND the solution: you have to define the icon name, which you first should create (add new image asset in Android Studio). When I don't define the icon, the notification will be generated with the default data....
wow, I tried to solve this for a while, you helped a lot, now it's working!
So @ragcsalo , do we define the icon in the object below after creating the image?
cordova.plugins.backgroundMode.setDefaults({
title: "helo",
text: "Text",
icon: 'icon',
color: "F14F4D",
resume: true
})
Hi @kevdaci, You have to look into the folder: \platforms\android\app\src\main\res In there you'll see folders like "mipmap-ldpi" Inside of those you'll see files named "ic_launcher.png"
You can use any icon, even those that are already there ...
Thanks! finally it works!!
@rodrigoti @ragcsalo @Taxi4you Could you provide an explicit example? I cannot get it to work... i still get the default notification that brings to the 'app info' setting page instead of bringing the app back up!
Something is off i guess: Does the color need the "#" before the hex digits like in css? do i need to add the extension (.png) to the icon name? does it have to be ldpi or hdpi? this is confusing for newbies who do not know what you are talking about exactly...
Readme is lacking in explicit details at https://github.com/katzer/cordova-plugin-background-mode#override-defaults ... oh well, ill try more stuff in the meantime and report back here!
Thanks in advance! :)
@kevdaci Can you be more specific? newbie here who does not understand what's what and where do files go/extension.png needed? etc... you seem to have a solution as others say 'thanks' but I cant make out what all of that means!
@boltex In your project directory of Ionic there should be a platforms folder. In that folder you should see an android folder (so basically ./platforms/android). Open that android folder using Android Studio. Once you opened the android project in Android Studio, if you look at the project side panel there should be a res folder. Right click on it and then click on New>Image Asset. A Configure Image Asset window should popup. Change the Name field to "icon", and then keep on clicking next. Build the ionic project as you usually would, and now you should click on the notification that would take you to the app instead of taking you to the information stuff.
Please let me know if this works. Now, I do not know how to change the default image, so you might have to do research on that, and tell me how to do that :) .
@kevdaci THanks! I've got it to work with this :
cordova.plugins.backgroundMode.setDefaults({
title: 'Dispatch Application',
text: 'Running in background',
icon: 'ic_launcher',
color: "0E4291",
resume: true,
hidden: false,
bigText: false
});
I'm just using cordova and the terminal window, no android studio IDE. so it looks like ic_launcher.png was a special icon that was available to use for that., seems to work, not sure if i'm doing the optimal thing....
Many thanks again!
@boltex
ionic4 You have to look into the folder: /platforms/android/app/src/main/res/mipmap-ldpi/ic_launcher.png
you must use without the .png extension ic_launcher
this.backgroundMode.setDefaults({ icon: 'ic_launcher', title: "AO VIVO - Rádio Farol FM 90,7", text: "Uma Nova História!", color: "ffffff", hidden: false, bigText: true, resume: true });
if you want to change the icon, add an icon to all folders
mipmap-hdpi mipmap-ldpi mipmap-mdpi mipmap-mdpi mipmap-xdpi mipmap-xxdpi mipmap-xxxdpi
This and the one done by me:
cordova.plugins.backgroundMode.enable();
cordova.plugins.backgroundMode.setDefaults(
title: 'Radio Matese',
text: 'Running in background',
icon: 'ic_launcher',
color: "ffffff",
resume: true,
hidden: false,
bigText: false
});
i put the ic_launcher image in all folders: mipmap-hdpi mipmap-ldpi mipmap-mdpi mipmap-mdpi mipmap-xdpi mipmap-xxdpi mipmap-xxxdpi
but it still doesn't work. Then another strange thing, when I put the app in the background and then I reactivate it, the app starts from the first screen and as if it restarts
@massimilianocom remember to put .png extension on the image file on disk tho.