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
Trusted Contributor
Posts: 103
Registered: ‎03-31-2011
My Device: Curve 9330
My Carrier: Verizon

App opening up wrong page after push.

This is my push page for a webworks phone app.  It works great.   It is run in the background. Not my main page( that is Home.htm) 

I have the wakeUpPage set to Home.htm

Yet After a push is sent this page opens up not the Home.htm 

 

How can I get it to Still open up on the Home page after a push?

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
	<head>
	   	<meta name="viewport" id="Meta1" content="initial-scale=1.0,user-scalable=no" />
	    <meta name="x-blackberry-defaultHoverEffect" content="false" />
		<link rel="stylesheet" type="text/css" href="css/pillButtons.css"><link />
		<title>Push Listener</title>
<script type="text/javascript">
  var port = 30447;
  var serverUrl = "http://pushapi.eval.blackberry.com";
  var appId = "myappID";
  var max = 100;
  var wakeUpPage = "Home.htm";

  function openBISPushListener() {

    try {
      var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : wakeUpPage, maxQueueCap : max};

      blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange);

    }
    catch (err) {
      alert(err);
    }
  }

  function onRegister(status) {

    if (status == 0) {
      //alert("success");
    }
    else if (status == 1) {
      //alert("network error");
    }
    else if (status == 2) {
      //alert("rejected by server");
    }
    else if (status == 3) {
      //alert("invalid parameters");
    }
    else if (status == -1) {
      //alert("general error");
    }
    else {
     // alert("unknown status");
    }
  }

  function onData(data) {

   <!-- var resultDiv = document.getElementById("resultDiv");-->
    try {
    blackberry.app.setHomeScreenIcon('local:///imgs/roostersicon48push.png');

      <!--resultDiv.innerHTML += "<br>" + blackberry.utils.blobToString(data.payload);-->
      return 0; //indicate acceptance of payload for reliable push
    }
    catch (err) {
      alert(err);
    }
  }

  function onSimChange() {
    var resultDiv = document.getElementById("resultDiv");
    resultDiv.innerHTML += "<br>" + "SIM card is changed!";
  }
</script>

	</head>
	<body onload="openBISPushListener()" bgcolor="#FFFF33">
       <!-- <table style="width:auto; height:inherit; background-color: #000000; margin-right: 0px;">
            <tr>
                <td>
                    &nbsp;</td>
                <td style="text-align: center">
                    <div id="resultDiv" style="font-size: medium; color: #000000;"></div>&nbsp;</td>

                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td style="text-align: center; vertical-align: middle">
                    <input id="Main Menu" value="Main Menu" type="button" onclick="location.href = 'Home.htm';" class ="button"
                        style="background-image: url('imgs/ButtonRed.jpg')"/></td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>

	    <p>
            &nbsp;</p>
        <p>
            &nbsp;</p>
-->
	</body>
</html>

 

Developer
Posts: 235
Registered: ‎11-08-2010
My Device: Not Specified

Re: App opening up wrong page after push.

I think the wake up page is only called if the app is closed when a push comes in. If you leave your app running in the background then the page its currently on will receive the push.

Trusted Contributor
Posts: 103
Registered: ‎03-31-2011
My Device: Curve 9330
My Carrier: Verizon

Re: App opening up wrong page after push.

hmmm ok. Then if I cannot use the body onload to redirect to the home page, where/how do I get it to goto the home page. Any Ideas?