question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trigger event does not work when the application is in the background

See original GitHub issue

I’m trying to generate (many, too many) local notifications from time to time, but due to the amount of notifications, I make them one by one, generating the first one, and with the trigger event, generating the next one, so that the application doesn’t crash. It works fine while the application is open, but when you move to the background, the trigger event stops working. I tried the cordova-plugin-background-mode plugin but it still doesn’t work. Is there a solution?

  • Plugin version: 0.9.0-beta.1
  • Platform: ios
  • OS version: 11.1.2
  • Device manufacturer / model: iPad and iPhone 5s
  • Cordova version (cordova -v): 6.5.0
  • Cordova platform version (cordova platform ls): ios 4.3.1
  • Plugin config
  • Ionic Version (if using Ionic)

Expected Behavior

When a local confirmation is triggered, the following must be generated with the trigger event

Actual Behavior

When you move to the background, no trigger event is triggered, therefore future local notifications are not generated.

Steps to Reproduce

document.addEventListener(‘deviceready’, function () {

	cordova.plugins.notification.local.on("trigger",function(notificacion,b){

		var datos_alerta={
                id: 1,
                title: "a title 2",
                text: "a text 2",
                trigger:{
                	at:   //some date in the future 
                }

          
            };
            cordova.plugins.notification.local.schedule(datos_alerta);

	});

cordova.plugins.notification.local.schedule({ id: 1, title: “a title”, text: “a text”, trigger:{ at://some date in the future } }); });

Context

I need to generate a local notification every time one is run, to update it with a new time

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
znegvacommented, Feb 1, 2018

As mentioned you need to add launch: true to the action-properties. And you should check launchDetails at every App-Start to recognise if the App was started by a local-notification (or one of its actions).

launchDetails does hold the notification-id and the event name (your action-id).

If you set the notification-id by yourself and need to recognise it later, be sure to use an 32-bit Integer.

1reaction
katzercommented, Jan 29, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Window Created" event trigger not working for background ...
If I open the background app, end its process in Task Manager, and reopen it, then the trigger does work. But if I...
Read more >
StackPanel does not trigger event related to drag when there ...
When background color is set, above problems are solved, i.e. events are triggered at anywhere in stackpanel.
Read more >
FileObserver does not triggering events while invoking in ...
The problem here is that the FileObserver is probably being garbage collected, as you can see here: Warning: If a FileObserver is garbage ......
Read more >
Event and notification is not triggering from the scheduled job
Hello All, I am facing issue with the scheduled job which is not triggering the Event and notification is not sending. The same...
Read more >
Simple Triggers | Apps Script - Google Developers
The script must be bound to a Google Sheets, Slides, Docs, or Forms file, or else be an add-on that extends one of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found