One aspect about coding natively for Blackberry that intimidates some developers coming from WebWorks or other environments is the use of an IDE -- Momentics in this case. BlackBerry has done a good job with the latest beta version of Momentics in making things much simpler than they were even a year ago. The interface is simple and presented in a much less intimating way with the new beta. So for this tutorial, we will be using the new native IDE version 10.2 Beta 1, which is available here.
Setting up your environment
When you launch Momentics for the first time you will see the following screen.
First thing you want to do is configure your BlackBerry targets (test device or simulator). You can connect to a test device (Dev Alpha, Q10, or Z10) via wifi or USB, and if you are using a simulator Momentics can automatically discover a simulator that is currently running on your PC. The target device is simply the device on which you want to deploy and test whatever application on which you will be working.
Configuring your target(s) is remarkably simple. First, enable development mode on your device settings (under security and privacy settings). Then, create a password on your device when prompted. Now, connect your device via USB (you can also use the device's wifi IP). So when the device is connected via USB, the IDE will detect and display confirmation that the device has been detected.
Click "Next" and you will be prompted for your device password.
Now that you have entered your password, click "Next" again and the IDE will confirm that all went well, and it will detect the OS version of the device. Now, the IDE prompts you for your to choose hte API level in which you want to work.
In this instance we will choose the Gold 10.1 SDK. Once you select the API level from the dropdown and click install, the IDE will download and install the selected SDK. Once installed, you are basically off to the races.
Registering Keys with the Signing Authority
Now that you have the SDK installed and everything basically all set up, this is a good time to go ahead and register your signing keys (a one time event). To do so, click the 'Window' menu, select preferences, click 'Blackberry' on the left vertical menu, then run the 'BlackBerry Deployment Setup Wizard'.
This step may have already been completed earlier in set up. If it looks familiar and you are sure you have done this already you can skip this section.
Once here, click next, then it will find and connect to any devices (which you already did) so move to the next screen. Hopefully you have requested keys via BlackBerry's website, but if you have not you can register for them at https://www.blackberry.com/SignedKeys/codesigning.html. One you request keys, you will receive two emails from BlackBerry within about 30 minutes (can take up to 2 hours) and these emails contain two certificates that you will use during this process.
IMPORTANT: Please do not forget the PIN you created when registering for your new keys on the Blackberry website!
So select the first option and click next.
Save the files attached to each email from BlackBerry somewhere on your hard drive, and from this screen locate and select the requested certificates by browsing for them on your hard drive. Now enter the PIN you created when you registered for the keys and then create a CSK Password and then confirm the password in the final field, and click next.
On the next screen you will be asked whther or not you want to backup your signing keys. Please do this, it may save your a lot of headache down the road. So simply choose a location and a file name, and the IDE will zip up the keys and save them wherever you wish.
Creating and uploading a Debug Token
Continuing form above, the next screen will prompt you to create a debug token. A debug token is a .bar file that is installed on your test device that allows you to deploy unsigned applications. This is a crucial part of testing bc you do not want to have to sign builds over and over simply to test your application.
It is important to point out that the current version or build number of an app can only be signed once, so when you update and build a new version, you have to change the version/build number in order to be able to sign the new version. Makes sense right?
So, to create a debug token simply choose the option to create a debug token and click next. Once you do so the IDE will create and upload the debug token to your device.
Finally, you will receive a confirmation screen to let you know all went well, and I am happy to report that you won't have to do that again unless you request new keys (and its a really simple process anyway). You are now ready to create, test, and sign BlackBerry 10 applications in Momentics.
Creating a Project
To start a new Cascades project choose "New" from the File menu and select "BlackBerry Project" from the pop-out menu. Then choose Cascades and press next.
On the next screen you can choose from one of the pre-designed templates, or you can start a blank empty project. Choose one and press next, name your project whatever you'd like, and you are now ready to begin coding a new app in the newest BlackBerry Native IDE.