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
Developer
contryboy
Posts: 68
Registered: ‎08-16-2012
My Device: BB10 Dev Alpha
My Carrier: NA
Accepted Solution

Does an application only to create channel once?

Dear All,

 

For an application to receive push message, does it only need to create channel once, and use the token for push in the future?

Or is it necessary to create channel every time the application is started?

 

Thanks,

Dong

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Does an application only to create channel once?

While you can create a new channel each time, you really shouldn't if you can avoid it. Each such request actually involves interaction with the server, so it will waste bandwidth, slow things down, and use resources that it shouldn't need to.

The token you get for the channel isn't needed just to receive pushes, however, but I guess you're talking about sending that to your push invoker to use in some sort of subscription process?

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
contryboy
Posts: 68
Registered: ‎08-16-2012
My Device: BB10 Dev Alpha
My Carrier: NA

Re: Does an application only to create channel once?

For creating channel, the doc says in some case (e.g. remove sim), it needs to create channel again. But how should I know when it is necessary to create the channel again? Would be safe to create it each time when the app is launched?

For the token, yes, that what I mean.

Thanks,
Dong
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Does an application only to create channel once?

For the example you gave, there's a signal to handle that: simChanged() (https://developer.blackberry.com/native/reference/cascades/bb__network__pushservice.html#function-si...

There are apparently other cases where it can happen as well, and it sounds like that area is under-documented and poorly handled. I've been told one case is where the user has used a backup to restore their device (or to a new device), in which case the channel will have been lost and needs to be created anew.

If your app will be run frequently, I would not advise creating a new channel each time, though for all I know that's what most people are doing. (I'm relatively new to Push stuff so don't take my words as expertise.)

If you have a way of detecting that the channel may need to be created again using your app's own logic, such as if an app should normally be receiving numerous pushes every day but a day goes by without any coming in, then that might be the best approach.

To handle the case of backup/restore... not sure. If you could track (saved in your data folder) the last OS version and device type that the app was running with, and that changes, that would cover some cases, but obviously not all.

Note that 10.2 appears to have some additional capability in the API that may be useful in this area, though I haven't tested it yet. (Specifically, the reconnect() and connectionClosed() stuff... though it doesn't seem to be specifically about channels so it may be unrelated.)

Last though that occurs to me: at least save a timestamp indicating when you last created the channel, and don't bother doing it again if the app runs within a short period of time after that, like a few hours. I think that's what I'll do in my app, until we can get more detail about these situations where the channel may be lost.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
contryboy
Posts: 68
Registered: ‎08-16-2012
My Device: BB10 Dev Alpha
My Carrier: NA

Re: Does an application only to create channel once?

Hi Peter,

Thanks for your detailed comment.
I think it seems hard to handle all the cases that need to create a channel. But your suggestion of handle it by app logic sounds reasonable. I will give it a try.

Dong
Please use plain text.