7. Connecting to the BlackBerry Dynamics Platform
Establishing a connection to the BlackBerry Dynamics platform requires authorisation of the end
user, and of the application. Both authorisations are initiated by a single function call.
To initiate authorisation processing, add code as follows.
A. Create an Event Handler
The results of authorisation processing are communicated to the application by the dispatch of
events. There are a number of approaches to implement handling of these events. This
workbook gives instructions for a particular approach that is easy to comprehend and extend.
The instructions in this section create a minimal handler, which is added to by later instructions.
The handler is a static singleton, i.e. a class of which there is only ever a single instance in the
program.
1. Open the application project in Xcode.
2. In the application menu, select File, New, File. Then select iOS, Source, and Cocoa
Touch Class and click Next. This opens a dialog on which you select the name and other
options for the new file.
Enter a name in the Class text box. One convention would be to use the same prefix as
the AppDelegate class and GDiOSDelegate as a suffix. In the Lazy Table Images
application, the AppDelegate class is named LazyTableAppDelegate, so the new class
could be named LazyTableGDiOSDelegate.
Leave the subclass as NSObject, select not to create a XIB file, and leave the language
as Objective-C.
Click Next. This opens a dialog on which you select where to save the new file.
Save the file in a directory that already contains class files for the application. In the Lazy
Table Images application, this is the Classes/sub-directory of the project directory.
Select the group Classes, if not already the default. Click Create to create the class.
You now have two new files, a .h file that contains the class declaration, and a .m file
that contains the class implementation.
3. Open the LazyTableGDiOSDelegate.h file.
Include the GDiOS.h header, by adding a statement like:
@import GD.Runtime;
Declare the class as implementing the GDiOSDelegate protocol.
Declare the class as having a static function, sharedInstance, that returns an instance
of itself.
The code should look like this: