Recently I tried out Cordova for BlackBerry OS 7 and earlier. I know BB7 isn’t exactly a new topic, and if a “trendy” developer chooses to dig into BB this moment, they might as well just start with BB OS 10. For me, I still use an “old-generation” BlackBerry, and being able to dev something for myself sounds pretty much attractive… plus, it’s my personal liking 😀
After a few days working with PhoneGap 2.7.0 (latest stable version at writing time) and Ripple Emulator 0.9.16 Beta (also latest version at writing time), I realize there’re a few possible headaches you might run into – even if you launch a fresh PhoneGap “HelloWorld” example project – meaning it’s not you who are at fault, but something else is being fishy. They are as follow:
1. Ripple Emulator will log a console message, denoting you have an issue with your app version or configuration. The exact message is this: “cordova :: Your application does not appear to match the platform you have selected. The version number in your configuration might not match the selected platform version or your configuration file has errors in it.”
Although this warning message doesn’t harm your app in any way, those fussy developers out there (like me) will not sleep soundly as long as the warning remains on screen. Here’s the solution: in your project “config.xml”, add the “gap” namespace attribute into the “widget” tag. The exact block of code to use is this:
xmlns:gap = "http://phonegap.com/ns/1.0"
And thus your config.xml “widget” tag may look something like this, in the end:
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:gap = "http://phonegap.com/ns/1.0" version="184.108.40.206" id="MyWonderfulApp">
With this configuration, Ripple will no longer display the warning. Happy eh!
2. The event “deviceready” doesn’t get fired.
At first sight, this appears to be a serious issue. In fact it took me days to understand the full story behind. The funny thing is: the event DOES get fired, but it’s only fired AFTER the system has done loading the file “cordova_plugins.json“. This file is not included in the default example project folder, and in fact this file may have any content as your app won’t be using it (at least for PhoneGap version 2.7.0). The browser behavior is that if it cannot find this file or this file exists but doesn’t have any content (empty text file), it will keep “pending” at that step, thus postponing the “deviceready” event till a much later time, when it finally times out.
You might be curious as to how I found out this.. Well I was testing my app, something like the 31st time.. without “deviceready” being fired. Being tired and worn out, I finally gave up and took a nap. It was when I woke up seeing the event fired did I realize the hows and whys of everything 🙂
So anyway, the solution is simple: create the “cordova_plugins.json” file in your project www folder with any content inside. For me I was using this text: “DUMMY”. After this, the browser won’t have any issues loading your app, and “deviceready” would finally be fired on time. Woah.. hope you guys haven’t been on fire for too long, trying to solve this funnily deadly issue!
Again, I’d love to note that this happens to me under these 2 conditions: Cordova version 2.7.0 and Ripple Emulator 0.9.16. You might not run into the same issues under different tools but if you do, I still hope this post would be able to provide some useful information.
Hope this helps 🙂
5 thoughts on “Developing for BlackBerry WebWorks OS7 or lower with Cordova / PhoneGap – Minor tips”
Hi, thanks for the information. Please I desperately need your help. I developed a mobile app for blackberry OS7 with Cordova 2.9.0 the deviceready works, on Ripple Emulator it display contacts but not on real blackberry device. Please help me what should I do?
Sorry the deviceready works on device also but does not displaying contact on device but it display contact on emulator
So sorry I reply to you this late. I haven’t been able to follow my blog recently.
If by any chance you’re still having issues with BlackBerry Cordova showing Contacts, I’d be more than happy to give a hand!
Since I haven’t looked at your code and configurations, I can’t tell what might go wrong, but I’m sure if you set up your www/config.xml and www/plugins.xml following this official instruction, then you’ll be able to display contacts just fine on a real device. I’ve tested it myself just now!
Also as a good practice, try to log whatever you can, be it “onSuccess” or “onError”, so that you always know what happens.
Great stuff khangdinh! Thanks for this article, it helped me track down one of the issues I was working on.
I am trying out blackberry 7 develop using phonegap.
but I don t find out the way for blackberry7 using phonegap
Just now i have full source code
I have read the article that bb7 is not supported by cordova.
But I want to develop bb7, please help me.
what is up?
At first I could not install phonegap 2.9
how could i install phonegap 2.9
And another thing
To build Blackberry 7, what framework would i need?
If you reply, I would think to thanks.