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
Posts: 14
Registered: ‎09-04-2011
My Device: BlackBerry Bold 9700 + PlayBook
Accepted Solution

Clearing Banner Indicator after receiving PUSH data

I current receive PUSH notifications and am able to update the app icon with a red flag and create a top notification icon using the showBannerIndicator from the API.

 

Does anyone know how to use removeBannerIndicator to clear the notification icon from the top bar?

 

To generate the notification icons when I receive PUSh I use:

 

function onData(data) {
  try {
    blackberry.utils.blobToString(data.payload);
    blackberry.app.setHomeScreenIcon("local:///images/notifyicon.png");
		blackberry.app.showBannerIndicator("images/bannerlogo.png");
		return 0;
    } 
    catch (err) {
      alert(err);
    }
  }

 To clear the home screen icon I do the following after the user has opens the app in the foreground to access the info:

 

function handleForeground() {
	inBackground = false;
	// Reset the app icons.
	blackberry.app.setHomeScreenIcon("local:///images/icon.png");
	blackberry.app.setHomeScreenIcon("local:///images/iconno.png", true);
}

 

I tried using blackberry.app.removeBannerIndicator() within that function hoping it would clear the icon until it receives a new PUSH but that clearly isn't working. The API documentation isn't very helpful either.

 

Hope someone could be of help on this.

 

Highlighted
Contributor
Posts: 14
Registered: ‎09-04-2011
My Device: BlackBerry Bold 9700 + PlayBook

Re: Clearing Banner Indicator after receiving PUSH data

Ok, figured this one out.

 

I create a seperate function and use that everytime the listen page comes to the foreground by doing a document load call:

 

blackberry.app.event.onForeground(whatever);

  function whatever(){
    blackberry.app.removeBannerIndicator();
    };

	$(document).ready(function(){
 		whatever();
	});

So each time the app comes to the foreground upon receiving a push, the first thing it does is clear the icon from the banner.

 

Hope this help someone who had a similar problem.