Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the notification info not working #506

Open
Taxi4you opened this issue Apr 19, 2020 · 15 comments
Open

Changing the notification info not working #506

Taxi4you opened this issue Apr 19, 2020 · 15 comments

Comments

@Taxi4you
Copy link

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

@kevdaci
Copy link

kevdaci commented May 4, 2020

I second that. Is there something wrong with the plugin?

@ragcsalo
Copy link

Same here.... the notification parameters couldn't be changed even if I edited the Java code... What the heck?? :-O

@ragcsalo
Copy link

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....

@rodrigoti
Copy link

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!

@kevdaci
Copy link

kevdaci commented May 15, 2020

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
    })

@rodrigoti
Copy link

rodrigoti commented May 15, 2020

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 ...

@Taxi4you
Copy link
Author

Taxi4you commented May 25, 2020

Thanks! finally it works!!

@boltex
Copy link

boltex commented Jul 20, 2020

@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! :)

@boltex
Copy link

boltex commented Jul 20, 2020

@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!

@kevdaci
Copy link

kevdaci commented Jul 20, 2020

@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 :) .

@boltex
Copy link

boltex commented Jul 20, 2020

@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!

@rodrigoti
Copy link

@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

@massimilianocom
Copy link

massimilianocom commented Jun 21, 2022

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

@boltex
Copy link

boltex commented Jun 22, 2022

@massimilianocom remember to put .png extension on the image file on disk tho.

@massimilianocom
Copy link

massimilianocom commented Apr 3, 2024

ok I managed to get it working, I wanted to ask how text could I also insert html tags?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants