Search code examples
htmlpluginscordovablackberrypush

Push Service plugin for BlackBerry WebWorks 2.0.0.54 error (Cordova 3.2) (newest versions of both SDKs)


I'm trying to use the Push Service plugin in my BlackBerry Webworks app (BB10 in HTML5).

I added the plugin through the command line like the documentation says, and checked that the com.blackberry.push folder was infact inside my plugins folder in my project. I ran the app in my device and the Web Inspector gave the next error:

TypeError: 'undefined' is not an object (evaluating 'window.webworks.defineReadOnlyField')

This error appears when the plugin tries to define the push constants like SUCCESS or INVALID_PPG_SUBSCRIBER_STATE, so obviously the plugin never starts to work and I can't use the push service.

I have my Push credentials fine (they work fine in my OS 7 app), and I was very carefull when I wrote the config.xml file. Here it is:

<widget id="Sample" 
xmlns="http://www.w3.org/ns/widgets" 
xmlns:cdv="http://cordova.apache.org/ns/1.0" version="0.0.1">
<name>Sample</name>
<license href="http://www.apache.org/licenses/LICENSE-2.0"/>
<author email="[email protected]" href="http://www.something.com">Something</author>
<content src="splash.html"/>

<access uri="http://www.mypushserver.com/Registro_Portalesv4/modules/Register" subdomains="true"></access>

<access origin="*"/>
<preference name="fullscreen" value="true"/>
<preference name="webviewbounce" value="true"/>
<description>Example</description>
<icon src="img/icono.png"/>
<feature id="blackberry.app"/>
<feature id="blackberry.push" />
<feature id="blackberry.system" />
<feature id="blackberry.invoked" />
<feature id="blackberry.ui.dialog" />
<feature id="org.apache.cordova" required="true" version="1.0.0" />
<rim:permissions>*
<rim:permit>access_shared</rim:permit>
<rim:permit>post_notification</rim:permit>
<rim:permit system="true">_sys_use_consumer_push</rim:permit>
<rim:permit>read_device_identifying_information</rim:permit> 
<rim:permit>access_pimdomain_messages</rim:permit>
<rim:permit>bbm_connect</rim:permit> 
<rim:permit>run_when_backgrounded</rim:permit>
</rim:permissions>
<rim:invoke-target id="example.sample.invoke.push">
<type>APPLICATION</type>
<filter>
<action>bb.action.PUSH</action>
<mime-type>application/vnd.push</mime-type>
</filter>
</rim:invoke-target>
<!-- Have an invoke entry here for when a notification is clicked on in the BlackBerry Hub -->
<!-- This will cause the application to be opened -->
<rim:invoke-target id="example.sample10.invoke.open">
<type>APPLICATION</type>
<filter>
<action>bb.action.OPEN</action>
<mime-type>text/plain</mime-type>
</filter>
</rim:invoke-target> 
</widget>

What I did notice was that the function "window.webworks.defineReadOnlyField" is located in the webworks-1.0.4.11.js file wich I don't have included in my project because I'm using cordova.js as the BlackBerry WebWorks Documentation, Upgrading to WebWorks 2.0 suggested. So I think that maybe the push plugin is not updated for the new SDK or I'm missing something as well.

Any ideas? Thanks in advanced!

PS: I'm porting my app from Phonegap Android, and worked fine when I ported it to Blackberry, except for the plugins, wich I had to add and adapt so they could work (except for the push plugin).


Solution

  • The problem solves by downloading the newest version of the PushService Plugin (updated 10 hours after I posted the question), that has fixed all the problems I mentioned on my question.

    Also, don't forget to add a tag with the ppg url to you config.xml file, otherwise the push service won't work.