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
New Contributor
thanhtrand
Posts: 9
Registered: ‎09-27-2012
My Device: Curve 9220
My Carrier: Viettel

Re: Push notifications in Webworks app

Hi Ryanthegiantlion,

 

Now I see the issues in your situation clearly and you helped me in "app in background" situation.

 

Do you know whether Blackberry webworks supports display badges or signs on app icon, play sound when app receives push (app is close or in background)?

 

Thanks.

 

 
Please use plain text.
Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer
My Carrier: n/a

Re: Push notifications in Webworks app

[ Edited ]

This is prob a bit off topic and deserves another thread . . .

So in short (AFAIK):

  • not sure about sound, this might help if it cant be down with webworks out of the box
  • You can add a status icon with showBannerIndicator() and specifiy a number
  • The app icon can be changed with setHomeScreenIcon, but you cant add a notification number or anything like that, you have to change entire icon.
Please use plain text.
New Contributor
thanhtrand
Posts: 9
Registered: ‎09-27-2012
My Device: Curve 9220
My Carrier: Viettel

Re: Push notifications in Webworks app

Hi Ryanthegiantlion,

 

Your information really helps me. Thank you.

 

P/S: I'm newbie in Blackberry development so please feel free ^-^ if my question off topic and deserves another thread.

I'll be aware it.

 
Please use plain text.
Contributor
hsekk006
Posts: 47
Registered: ‎01-29-2013
My Device: BB10
My Carrier: BlackBerry

Re: Push notifications in Webworks app

Hello,

 

I'm using push-enabled application to listen to the pushes of the push Initiator application, but the openBISPushListener() method it's not lestening to my pushes in the device I got an error (can't find variable: blackberry) as an alert in the device .

 

This application is for BB10 (Is still the BIS supported and available in BB10).

 

Thanks.

Please use plain text.
Contributor
hsekk006
Posts: 47
Registered: ‎01-29-2013
My Device: BB10
My Carrier: BlackBerry

Re: Push notifications in Webworks app

 

 

I'm using push-enabled application to listen to the pushes of the push Initiator application, but the openBISPushListener() method it's not lestening to my pushes in the device I got an error (can't find variable: blackberry) as an alert in the device .

 

This application is for BB10 (Is still the BIS supported and available in BB10).

 

Thanks.

Please use plain text.
Contributor
hsekk006
Posts: 47
Registered: ‎01-29-2013
My Device: BB10
My Carrier: BlackBerry

Re: Push notifications in Webworks app

Hello,

 

I'm using push-enabled application (little bit same as yours) to listen to the pushes of the push Initiator application, but the openBISPushListener() method it's not lestening to my pushes in the device I got an error (can't find variable: blackberry) as an alert in the device .

 

This application is for BB10 (Is still the BIS supported and available in BB10).

 

Thanks.

Please use plain text.
Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer
My Carrier: n/a

Re: Push notifications in Webworks app

From

http://developer.blackberry.com/html5/api/blackberry.push.html

we see that openBISPushListener() is not supported in BB 10. The push object that you need to use for BB10 has changed: 

http://developer.blackberry.com/html5/apis/blackberry.push.pushservice.html

That said, if blackberry is not defined then I suspect there is also a chance you are trying to register for push too early. Make sure you only call the push methods after device is ready (by listening to the onDeviceReady). And dont forget your config permissions . . .

Hope that helps.


Please use plain text.
Contributor
hsekk006
Posts: 47
Registered: ‎01-29-2013
My Device: BB10
My Carrier: BlackBerry

Re: Push notifications in Webworks app

Thank you very much for your help

 

How could I listen to the onDeviceReady and to the pushes in BB10?

 

What will be the method in BB10 that replace the openBISPushListener, please?

 

Please use plain text.
BlackBerry Development Advisor (Retired)
mdandrea
Posts: 311
Registered: ‎08-08-2012
My Device: BlackBerry Z10
My Carrier: Rogers

Re: Push notifications in Webworks app

Please see this page: https://developer.blackberry.com/devzone/develop/platform_services/push_apps.html

 

We provide a detailed example and developer guide for building BB10 WebWorks apps using the new push APIs.

 

Thanks,

 

Matt

Please use plain text.
Contributor
hsekk006
Posts: 47
Registered: ‎01-29-2013
My Device: BB10
My Carrier: BlackBerry

Re: Push notifications in Webworks app

If I want to use the code in the hyperlink that you gave to me for my application, could I just put it in my device and send the pushes from my Initiator push, is that will work.

 

Would you like to tell me please what are the steps to do to lesten to the server pushes

1. Is it to lunch the Push Initiator first and after that click in the push enabled in the device BB10.

or

2. Is it to lunch the Push Initiator first and let the push enabled liten alone to be invoked after that.

 

This is what I'm using on my Push Initiator

<?php  
   if ($_POST) {
          //CPID (Content Provider ID)
          $appid = ' ';
          //Password provided by RIM
          $password = ' ';
       
          //Deliver before timestamp
           $deliverbefore = gmdate('Y-m-d\TH:i:s\Z', strtotime('+5 minutes'));
   
           $addresstosendto[] = $_REQUEST['bbpin'];      //push only to a specific pin
   
           $addresses = '';
           foreach ($addresstosendto as $value)
    {
           $addresses .= '<address address-value="' . $value . '"/>';
        }
   
       // create a new cURL resource
       $err = false;
       $ch = curl_init();
       $messageid = microtime(true);    
   
       $message = $_POST['message'];
         
       $data = '--mPsbVQo0a68eIL3OAxnm'. "\r\n" .
      'Content-Type: text/plain; charset=UTF-8' . "\r\n\r\n" .
      '<?xml version="1.0"?>
      <!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd">
      <pap>
      <push-message push-id="' . $messageid . '" deliver-before-timestamp="' . $deliverbefore . '" source-reference="' . $appid . '">'
      . $addresses .
      '<quality-of-service delivery-method="unconfirmed"/>
      </push-message>
      </pap>' . "\r\n" .
       '--mPsbVQo0a68eIL3OAxnm' . "\r\n" .
      'Content-Type: text/plain' . "\r\n" .
      'Push-Message-ID: ' . $messageid . "\r\n\r\n" .
       stripslashes($message) . "\r\n" .
       '--mPsbVQo0a68eIL3OAxnm--' . "\n\r";   
       
       //curl_setopt($ch, CURLOPT_URL, "https://cpXXX.pushapi.eval.blackberry.com");  //PPG URL
       curl_setopt($ch, CURLOPT_URL, "https://cpXXX.pushapi.eval.blackberry.com/mss/PD_pushRequest");  //PPG URL  
       curl_setopt($ch, CURLOPT_HEADER, false);
       curl_setopt($ch, CURLOPT_USERAGENT, "SAA push application");
       curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
       curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
       curl_setopt($ch, CURLOPT_USERPWD, $appid . ':' . $password);
       curl_setopt($ch, CURLOPT_POST, 1);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
   
       // grab URL and pass it to the browser
       $xmldata = curl_exec($ch);
   
       // close cURL resource, and free up system resources
       curl_close($ch);
   
       //Start parsing response into XML data that we can read and output
       $p = xml_parser_create();
       xml_parse_into_struct($p, $xmldata, $vals);
       $errorcode = xml_get_error_code($p);
       if ($errorcode > 0)
       {
           $err = true;
       }

       xml_parser_free($p);
   
       echo 'Our PUSH-ID: ' . $messageid . "<br \>\n";
       if (!$err && $vals[1]['tag'] == 'PUSH-RESPONSE') {
           echo 'PUSH-ID: ' . $vals[1]['attributes']['PUSH-ID'] . "<br \>\n";
           echo 'REPLY-TIME: ' . $vals[1]['attributes']['REPLY-TIME'] . "<br \>\n";
           echo 'Response CODE: ' . $vals[2]['attributes']['CODE'] . "<br \>\n";
           echo 'Response DESC: ' . $vals[2]['attributes']['DESC'] . "<br \> \n";
       } elseif ($err) {
           echo '<p>An XML parser error has occured</p>' . "\n";
           echo '<pre>' . xml_error_string($errorcode) ."</pre>\n";
           echo '<p>Response</p>' . "\n";
           echo '<pre>' . $xmldata . '</pre>' . "\n";
       } else {
           echo '<p>An error has occured</p>' . "\n";
           echo 'Error CODE: ' . $vals[1]['attributes']['CODE'] . "<br \>\n";
           echo 'Error DESC: ' . $vals[1]['attributes']['DESC'] . "<br \>\n";
           echo '<pre>' . $xmldata . '</pre>' . "\n";
           var_dump($xmldata);
       }
   } else {
       showhtml();
   }
   
   function showhtml() {
       ?>
       
   <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>" accept-charset="UTF-8" enctype="application/x-www-form-urlencoded">
   <p>BB PIN</p>
   <input type="text" name="bbpin" size="15" value="" />
   <br />
   <br />
   <p>Message to push:</p>
   <textarea name="message" rows="5" cols="80"></textarea>
   <p></p><input type="submit" value="Push Data" onClick="getLocation()"></p>
   </form>
   <?php
   }
   
   ?>
  

Please use plain text.