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

how to remove notification #179

Closed
winos opened this issue Aug 23, 2016 · 24 comments
Closed

how to remove notification #179

winos opened this issue Aug 23, 2016 · 24 comments

Comments

@winos
Copy link

winos commented Aug 23, 2016

when the app is running in background, show a notification always with this message:

App is running in bakground

How can i do remove it? It is never removed

@katzer
Copy link
Owner

katzer commented Aug 25, 2016

@winos Use the silent mode See the sample app and the readme
https://github.com/katzer/cordova-plugin-background-mode/tree/example

@ptp5833
Copy link

ptp5833 commented Sep 2, 2016

cordova.plugins.backgroundMode.setDefaults({ silent: true });

i already used silent true . however after updated.
now version 0.6.5 .... the message showed. how can i hide the message..?

@fenglu09
Copy link

I had the same issue too。My version is: 0.6.5 and android version: 6.0

@hoongoon86
Copy link

hoongoon86 commented Sep 21, 2016

Same issue here. Android 5.0.1 and 6.0

@ouarrar
Copy link

ouarrar commented Sep 24, 2016

Hi,
I find a solution to remove notification by updating the source file "cordova-plugin-background-mode/src/android/ForegroundService.java".
remove "startForeground(NOTIFICATION_ID, makeNotification());" line 105 and insert this lines:

Notification note = new Notification( 0, null, System.currentTimeMillis() );
note.flags |= Notification.FLAG_NO_CLEAR;
startForeground( NOTIFICATION_ID, note );

I use Ionic Framework its work for me

@hoongoon86
Copy link

hoongoon86 commented Sep 28, 2016

Solution from @ouarrar works great.
Just make sure that you set none of default or config settings.
However, There's another notification message pops up when the app goes to background.
It says,

App is running. Touch for more information or to stop the app

which is caused by startForeground().

Update:
So, I've just removed
startForeground(NOTIFICATION_ID, makeNotification());
as well as
Notification note = new Notification( 0, null, System.currentTimeMillis() );
note.flags |= Notification.FLAG_NO_CLEAR;
startForeground( NOTIFICATION_ID, note );
and it seems it works good to me (Android 5 and 6).
My app uses background for timer and alert, notification

@igor90
Copy link

igor90 commented Oct 4, 2016

Hi, i have the same problem with silent: true. Notification shows logo without any text and it i can't close or open app clicking on this notification.

ForegroundService.java file has "startForeground(NOTIFICATION_ID, makeNotification());" but it not on 105 line. So i removed it and added another code from @hoongoon86 post but it doesnt help.
Please show me your code from ForegroundService.java file

Thanks!

@fenglu09
Copy link

fenglu09 commented Oct 8, 2016

Hi everyone,after I set cordova.plugins.backgroundMode.setDefaults( silent: true), the nootification was gone.

@igor90
Copy link

igor90 commented Oct 10, 2016

@fenglu09 Thank you for your response. Your solution it is not quite right for me.

I want app to work without notification(silent true), but after some users actions i want app to show some notification. And it works but sometime app shows empty notification - only logo without any text.
How to hide the empty notification?

It is my code:
http://pastebin.com/x40xzgcb

@fenglu09
Copy link

fenglu09 commented Oct 10, 2016

Have you set the text or title properties?

@igor90
Copy link

igor90 commented Oct 10, 2016

Yes, I set the default settings:
cordova.plugins.backgroundMode.setDefaults({
title: 'My App',
text: 'You have running service!'
});

Screen what i see http://coment.me/RvusJZe

@fenglu09
Copy link

Well, I don't know how to solve it too.

@igor90
Copy link

igor90 commented Oct 10, 2016

@fenglu09 Thank you, anyway!

I will try to write more details about my problem

  1. Installed app with all permissions
  2. I ran app
  3. I sent app to tray
  4. I locked the screen by few seconds
  5. I unlocked the screen
  6. Empty notification appeared

Android version 5.1
cordova version 6.3.1
cordova-plugin-background-mode 0.6.5 "BackgroundMode"

By the way i set "silent: true" in default settings, but this bug in any case is there

Thanks!

@katzer katzer added the bug label Jan 1, 2017
@katzer
Copy link
Owner

katzer commented Jan 1, 2017

@igor90, did you had the chance to test with v.0.6.6-dev (master)? I've fixed the silent mode in the meantime.

@katzer
Copy link
Owner

katzer commented Jan 2, 2017

Please re-open if still present with latest master branch (0.6.6)

@katzer katzer closed this as completed Jan 2, 2017
@ronaiza-cardoso
Copy link

ronaiza-cardoso commented Jan 31, 2017

I'm using cordova.plugins.backgroundMode.configure({ silent: true }); and the notification is still shown. I have cloned from branch

@katzer
Copy link
Owner

katzer commented Feb 10, 2017

Now it should work!

@kyomaya
Copy link

kyomaya commented Mar 17, 2017

Please, reopen the issue.
I'm still having trouble in android 6. I'm using cordova 6.3.1 and ionic 1 and angular 1 too.
In android 5, it seens to work OK, but in android 6 I still get the "Application is doing heavy tasks" notification after a while when the app is in background.

Here is my code:
// in app.js
if( ionic.Platform.isAndroid() ) {
cordova.plugins.backgroundMode.setDefaults({
silent:true
});
if(!cordova.plugins.backgroundMode.isEnabled()){
cordova.plugins.backgroundMode.enable();
}
}

//in my controller

document.addEventListener('deviceready', function () {
var onPauseInterval = null;
var onlogInterval = null;
var iteracoes=1;

document.addEventListener("pause",onPause,false);
document.addEventListener("resume",onResume,false);

function onPause() {
log("onPause...");

};

function onResume() {
log("onResume...");
clearInterval(onlogInterval);
//cordova.plugins.backgroundMode.disable();
};

cordova.plugins.backgroundMode.on('activate', function () {
log("On activate...Timer= "+settings.timer);
cordova.plugins.backgroundMode.disableWebViewOptimizations();
log("disableWebViewOptimizations");
var i=1;
onPauseInterval = window.setInterval(function() {
log("reloadAllBackGround "+i);
$scope.reloadAllBackGround();
i++;
}, (1000*60)*settings.timer);

onlogInterval = window.setInterval(function() {
  iteracoes++;
  log("Total time running == "+(iteracoes*5));
}, (1000*60)*5);

});

});

Thanks in advance.

@fernandominardi
Copy link

fernandominardi commented Apr 7, 2017

Please, reopen the issue.
I'm using v0.6.6-dev and the notification appears right away.
Thanks for the effort.

@noluckskills
Copy link

@N7snake If you want to hide the notification you can do like this :

cordova.plugins.backgroundMode.setDefaults({ 
        title:  'TheTitleOfYourProcess',
        text:   'Executing background tasks.',
		silent: true
    });

@faustoct1
Copy link

faustoct1 commented Sep 6, 2017

@noluckskills it minimize but didn't solve to me. At certain point the notification suddenly appears. I don't know exactly the scenario but shows up. Got many user's complain specially by the message not to be friendly.
"App is running in back. Doing have tasks." is not a kindly message users like to see.

@katzer Is there a straight way to fix/silent it ?

my code very simple:

        cordova.plugins.backgroundMode.setDefaults({ silent: true })
        cordova.plugins.backgroundMode.configure({})

        cordova.plugins.backgroundMode.on('activate', function() {
           cordova.plugins.backgroundMode.disableWebViewOptimizations();
        });

        cordova.plugins.backgroundMode.on('deactivate', function() {
           cordova.plugins.backgroundMode.enableWebViewOptimizations();
        });

        cordova.plugins.backgroundMode.on('enable', function() {
        });

        cordova.plugins.backgroundMode.enable();

@ya55en
Copy link

ya55en commented Dec 27, 2017

Setting defaults as shown:

backgroundMode.setDefaults({
  title: 'My App Name',
  text: 'Checking for new info',
  silent: true,
})

works fine for me on Android 6.0 (this is ionic3/angular5).

@faustoct: not sure what your issue may be, but it seems there's no cordova.plugins.backgroundMode.enableWebViewOptimizations() on the first place (or I don't find it in the documentation).

@githubRavindra
Copy link

githubRavindra commented Apr 16, 2018

for modify notification ====== Ionic3 (write code in app.component.ts)====

cordova.plugins.backgroundMode.setDefaults({
title: String,
text: String,
icon: 'icon' // this will look for icon.png in platforms/android/res/drawable|mipmap
color: String // hex format like 'F14F4D'
resume: Boolean,
hidden: Boolean,
bigText: Boolean
})

for hide notification

cordova.plugins.backgroundMode.setDefaults({ silent: true });

[(https://github.com/katzer/cordova-plugin-background-mode)]

@manikandan-bambus
Copy link

Solution from @ouarrar works great.
Just make sure that you set none of default or config settings.
However, There's another notification message pops up when the app goes to background.
It says,

App is running. Touch for more information or to stop the app

which is caused by startForeground().

Update:
So, I've just removed
startForeground(NOTIFICATION_ID, makeNotification());
as well as
Notification note = new Notification( 0, null, System.currentTimeMillis() );
note.flags |= Notification.FLAG_NO_CLEAR;
startForeground( NOTIFICATION_ID, note );
and it seems it works good to me (Android 5 and 6).
My app uses background for timer and alert, notification

Thanks

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

No branches or pull requests