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
Contributor
lawillas
Posts: 17
Registered: ‎06-18-2012
My Device: Bold 9900
Accepted Solution

Live feed feature on webworks app

Hi Guys,

               So i'm trying to create an app that constantly needs to get data from a server at very regular intervals. Now I know everyone would be jumping to their feet and saying "PUSH NOTIFICATION" but just before you all make that conclusion, pls consider the following conditions.

 

1. Each user would be logged in to access the app and would receive data based on different variables set (different users receiving different content)

2. There would be a high volume of data being received in a day so i'm a little scared about the push notification push quota.

3. I need the app to work just like the way the twitter clients for blackberry work. Where new tweets are automatically loaded even when the user is not in the foreground of the application. 

 

My greatest concern with using push notification is the various factors that are considered before determining what data a user receives. Please also note that I have implemented push notification in a previous app and it works great but i'm seriously looking at other options for this solution. Web sockets would have been a great option but its only available on bb 0S 7+

BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: Live feed feature on webworks app

Until the last sentence my mind was with Web Sockets :-) Which OS versions are you looking to support?

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.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Live feed feature on webworks app

How frequent are the updates? Can you pull the data on an interval?
Contributor
lawillas
Posts: 17
Registered: ‎06-18-2012
My Device: Bold 9900

Re: Live feed feature on webworks app

I am looking to support os 5+ (os 5, os 6, os 7 and BB 10). Yes getting the data at intervals would be the way to go certainly but the interval has to be a small one like 5sec because the key is for users to get the data almost as its available. 

BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: Live feed feature on webworks app

It seems to me that push may be the ideal candidate here in conjunction with polling. You noted a few concerns:

 

1. Each user would be logged in to access the app and would receive data based on different variables set (different users receiving different content)

This logic could be implemented on the server-side before the push takes place. Using a more powerful PC / server to determine the appropriate data to send to individual users. The efficiency would be based on the server-side implementation.

 

2. There would be a high volume of data being received in a day so i'm a little scared about the push notification push quota.

Indeed, depending on the user-base and frequency of updates this could be a concern. The advantage is that you're only sending network communictions when required (i.e. you don't send a push every 5 seconds unless there is new data.) Even the Twitter application will tend to have ~20 seconds between updates even during busy times.

 

You could combine technologies (i.e. a push that simply indicates when there is new content, then hand it off to another transport route for polling / etc.  during busy times to minimize pushes. Then, once polling shows nothing for a while, wait for the next push to come through.) Admittedly the logic in identifying "busy times" and offloading from push to polling will take a bit of implementation work.

 

3. I need the app to work just like the way the twitter clients for blackberry work. Where new tweets are automatically loaded even when the user is not in the foreground of the application. 

This asks for push.

 

I am looking to support os 5+ (os 5, os 6, os 7 and BB 10).

As noted, this rules out Web Sockets if you're looking for one solution across the board. A combination of Push Notifications and polling is likely best here. I would recommend that 5s may be a bit fast and would recommend something closer to 20; the reason being that if it truly is a busy period, are 5s enough to view any of the information coming in in the first place? Just something to consider.

 

 


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.
Contributor
lawillas
Posts: 17
Registered: ‎06-18-2012
My Device: Bold 9900

Re: Live feed feature on webworks app

Thanks for your points @Oros. I think your logic sounds reasonable enough. I'll think it out and work it all out. One question though (just a little education). When I hear about polling, polling, polling; for a web works app, is this an equivalent of making ajax calls at intervals? If true, what would be the state of the app when not in the foreground mode. My first guess is that ajax calls would still continue but not completely sure because they say the state of javascript is lost when the page is not opened

BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: Live feed feature on webworks app

You are correct regarding polling. Basically the client sends an Ajax request to see if there is new data and the server responds with the status or the new data.

In order to enable Javascript and networking execution while the application is minimized (i.e. running, but not foregrounded), you will need to request the run_when_backgrounded permission:
https://developer.blackberry.com/html5/documentation/rim_permit_element.html

If you are including the blackberry.push <feature>, you get this functionality by default as well.

That being said, if the application is closed, you will not be able to execute polling, and will only be able to listen for incoming push notifications.

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.