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
andrewbc
Posts: 11
Registered: ‎04-11-2014
My Device: Z-10

Re: pushCaptureBasics: I can register, I can initiate push - but never see a push message

I hacked up the pushClient index.html to do what you suggested. At line 48 (after /*global window, document, blackberry, pushClient */) I added:

            var wasInvoked = new Date().getTime();
            window.localStorage[wasInvoked] = 'A';

 

Then at line 80 (right after /* Listen for invoke requests. */) I added an invoked event listener before the existing event listener:


             /* Listen for invoke requests. */
            document.addEventListener('invoked', function onInvoked() {
            wasInvoked = new Date().getTime();
            window.localStorage[wasInvoked] = 'B';
            }, false);
            document.addEventListener('invoked', pushClient.onInvoke);

 

When I print localStorage from the console, I don't see 'A' or 'B'.

window.localStorage
Storage {}
constructor: StorageConstructor
lastActivity: "1398816359458"
length: 1
__proto__: StoragePrototype

 

Not sure what went wrong here... I can see that pushClient.js is updating lastActivity, but I'm not getting anything from the script in index.html. That's running in the event listener for deviceready - but I don't think that would be a problem.

 

Here's my diff from pushClient's index.html:

diff index.html index.html.orig
49,51d48
<                       var wasInvoked = new Date().getTime();
<                       window.localStorage['A'] = 'A';
<                       window.localStorage[wasInvoked] = 'A';
58,60d54
<                       window.localStorage['C'] = 'C';
<                       wasInvoked = new Date().getTime();
<                       window.localStorage[wasInvoked] = 'C';
85,89d78
<                       document.addEventListener('invoked', function onInvoked() {
<                       window.localStorage['B'] = 'B';
<                       wasInvoked = new Date().getTime();
<                       window.localStorage[wasInvoked] = 'B';
<                       }, false);

 

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: pushCaptureBasics: I can register, I can initiate push - but never see a push message

Interesting...

 

I'm going to do a full run-through of the application here. There's definitely something peculiar going on here and this way I'll either reproduce the issues you are seeing, or we'll have a baseline for comparison against your own application.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: pushCaptureBasics: I can register, I can initiate push - but never see a push message

I've managed to track this down I think.

There is a plugin that is mentioned in the docs, but not explicitly told to add it to the client. This API (blackberry.app) is used during startup and seems to (sometimes) be causing execution to break.

Could you please execute:
webworks plugin add com.blackberry.app

To include this plugin in your project?

The pushCaptureBasics sample will include this step shortly. Beyond that, I wasn't able to produce any issues so hopefully that is it.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.