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

Native Development

Reply
Contributor
R4BB
Posts: 19
Registered: ‎03-05-2013
My Device: 9700

PushSevice: How can I remove duplicate call of createChannel() when my application launched

[ Edited ]

Hi Friends,

 

Can someone help me to find the write way

 

Actually I trying to use the PushService on BIS.

 

I create a Session by calling createSesstion() on pushServeice object., after that on session created successfully then I call createChannel on pushServeice object. (This is two sequential step procedure)

 

Since according the doc ,

 

1. Create session sets up inter-process communication between the application and the PNS agent. This must be called every time the application is launched.

 

And

 

2. Creates a channel for receiving push messages from the Push Initiator. Once the channel is successfully established, the application does not have to call this again.

 

Since I am calling these two call in sequential every time when application is launched ,

 

Does we have any way to know that I already created channel before, now this time does not require this call again. ??

 

Please suggest me, how can I avoid the next createChannel call ?

 

Your reply are valuable for me. Thanks in advance

 

 

 

 

 

Developer
dkonigs
Posts: 256
Registered: ‎07-25-2008
My Device: Passport

Re: PushSevice: How can I remove duplicate call of createChannel() when my application launched

Right now there is no way to know if you've already created a channel.  So the best solution is to just save a setting value inside your app that says "I've created a push channel already".  Then, if that value is set, don't create a channel again.

 

However, you may also want to save the device serial number, OS version, and a few other things along with that value.  If any of those change, then try creating the channel again.

 

This is because if a user does a backup/restore of their device, the push registration may be lost, and you'll have to call create channel again.

Contributor
R4BB
Posts: 19
Registered: ‎03-05-2013
My Device: 9700

Re: PushSevice: How can I remove duplicate call of createChannel() when my application launched

Hi dkoings,

Thanks for reply , since there is no way to found that channel is already exist or not, so for safety side I should always call create channel.
Developer
dkonigs
Posts: 256
Registered: ‎07-25-2008
My Device: Passport

Re: PushSevice: How can I remove duplicate call of createChannel() when my application launched

I don't think BlackBerry wants people calling createChannel() every time.  It also has some network/server overhead, and may take some time to process.

 

I suggest instead trying to track a few bits of information that identify the device and OS, and only call it again if those change.  (and maybe a timestamp, so you also call it again if its been a few weeks)