Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
Contributor
Posts: 21
Registered: ‎02-06-2012
My Device: PlayBook, Dev Alpha C, Red Z10, Black Z10
My Carrier: NIL
Accepted Solution

setTimeout stops working once my app is signed

I have found a bug which appears to have come with a recent update of the BlackBerry OS 10.2.1.x.  Until just recently, my app worked fine.

 

When I use window.setTimeout() in my WebWorks "debug" project, my app is capable of sending notifications whether the screen is on or off.  That is, obviously, the desired outcome.  However, as soon as I build and sign the app (no longer debug), the notifications will ONLY work if:  1) The screen is on AND 2.1) The app is actively running in "full screen" mode OR 2.2) The app is running in "cover" mode, and the current view is the "cover view" mode.  Ex.: if I'm on one of the app pages or in the hub, the notification will NOT work until I swipe over the "cover view" mode.

 

More specifically, here's my code:


var reminders = [];

function setReminders(seconds, title, body, tag) {

reminders.push(setTimeout(function(){
new Notification(title, {body:body,tag:tag});
}, seconds * 1000));

}

 

I am using bbUI.js 0.9.6.1894, though I don't see that that should make any difference, and BlackBerry Software Release 10.2.1.2977 and OS Version 10.2.1.3247.

 

So the all-important question is: how can I get my notifications working once my app is actually signed?  It's really hard because it just works as long as my app is debuggable.  

Contributor
Posts: 21
Registered: ‎02-06-2012
My Device: PlayBook, Dev Alpha C, Red Z10, Black Z10
My Carrier: NIL

Re: setTimeout stops working once my app is signed

[ Edited ]

I found the answer to my conundrum - I don't know how I missed it.  Simply add the rim: permit "run_when_backgrounded" as described on this page: https://developer.blackberry.com/html5/documentation/v2_1/rim_permit_element.html

 

I used the config.xml setting, though I don't doubt that the plugin would work equally well.