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

BlackBerry Push Development

Reply
Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Nope, I just got back from vacation :smileytongue:

 

Still battling...

Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer

Re: Push notifications in Webworks app

May the force be with you! :-p

Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

marco_dicesare, do you any more ideas on this, please?

Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Hello again, has anyone found a solution for this? Still fighting... :smileytongue:

Retired
marco_dicesare
Posts: 76
Registered: ‎08-08-2012
My Device: BlackBerry Z10

Re: Push notifications in Webworks app

Sergio please send me a PM with your email address and I will try and help you offline. When we figure it out we'll post the solution back to this forum.

Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer

Re: Push notifications in Webworks app

Any developments here? This problem has reappeared for me in another app. On BB OS 5.0 I receive push notifications when the app is closed or when running in the foreground but not when that app is running in the background.

If the app receives push notifications while running in the background the app just freezes the entire operating system when reopened. There is no further response to any input as far as I can tell and I am force to reboot (pull the battery).

Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Not yet ryan, still trying to solve it... I'll post any developments here.

Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer

Re: Push notifications in Webworks app

I finally had a breakthrough here. The problem in my case was calling alert() in the OnData method.
There seems to be a bug calling alert when the program is in the background. 

I still have to investigate whether the alert() just throws an exception or if the program just crashes at that point. It could be either because alert() is called in the catch block again so the program could be thowing two exceptions with the later exception being uncaught.

Anyway, i change the line: 

 

alert(blackberry.utils.blobToString(data.payload));

to log to a 'console div' which I now use for debugging and pushes when the app is in the background have been fixed.

New Contributor
thanhtrand
Posts: 9
Registered: ‎09-27-2012
My Device: Curve 9220

Re: Push notifications in Webworks app

Hi Ryanthegiantlion,

 

Thanks for your information.

 

I have some points unclear. If push comes while app is being closed, app just launched in background. If push comes while app is in background, nothing happens. Function onData just be called if you open app.

 

function onData(data) {
    try {
        $.mobile.changePage("alles.html");
        return 0; //indicate acceptance of payload for reliable push
    }
    catch (err) {
        //alert(err);
    }
}

 

I also found this from https://developer.blackberry.com/html5/apis/blackberry.push.html#.openBISPushListener

 

"If an application registered to BIS push is closed and a push message arrives, the application will be launched in background and the wake up page is displayed. rim:allowInvokeParams="true" attribute must be specified in the content element of config.xml."


So do you think that if push comes while app closed, app will be launched in background?

Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer

Re: Push notifications in Webworks app

[ Edited ]

Hi thanhtrand,

 

Let me try clear up what the exact problem was in my case, what the cause is, how I isolated it and what I think the issue is . . .

The problem:
My program receives push notification correctly when it is open and when it is closed. When closed, the app opens in the background when a push is received and the javascript is executed in the background concurrently to whatever else the user is doing. This when-closed behaviour requires that you specifiy the invokeparameters in your config(as you pointed out) and that you specify the wake up page in your javascript.
However when the app is in the background and I receive a push, the app freezes the entire OS when I try open it again. This only occurs when I call alert() in the OnData method . . . removing that fixed the problem. Btw, as far as I know when the program is in the background the OnData will be called when the push is received, not when the app is reopened . . .

How I isolated the problem:
FIrstly, I made sure that I just had an alert('Data received') in my onData method (and a return 0). Changing that alert to write to a div fixed the problem. 
Secondly, it is worth putting out that whether the app is in the background, closed or foreground can be controlled programitically and a few of the push java script handlers that I have seen on this forum do that (I have also noted that some apps like gmail do this). Basically they override the default behaviour of the close key etc and rather push the app to the background. In my case, when I say background, foreground or closed I mean exactly that and verified the state using a combination of time staps and the blackberry version of 'alt-tabbing' through the current apps in memory to see what is open in the background.

My theory:
So the issue seems to be with alert when the app is in the backgound. I suspect that it has something to do with the blocking nature of the alert call. In other words, something is being blocked that needs to run only in the case when the app is in the background which causes an uncaught exception somewhere.

Hope that helps and clarifies the issues in my case at least. If not, just give me a shout . . .

 

Edit: I should also point out that this had only been verified to be the case on OS 5.0. OS 6.0 up has a completely different browser engine so it might not be the case there. . .