BlackBerry Dynamics

Get Started with BlackBerry Development Tools

Get Started with BlackBerry Dynamics SDK

Develop your first secure mobile app now at no cost with the help of the powerful BlackBerry Dynamics Secure Mobility Platform.

The BlackBerry Dynamics Platform provides a range of SDKs and plugins that allow you to develop in the environment of your choice and build native, hybrid, or web apps. 

Choose a platform and click Next.

Discover the components and benefits of the BlackBerry Dynamics Secure Mobility Platform. This resource provides information about using the BlackBerry Dynamics SDK for iOS, Android, and Cordova. For more information about using the SDK for all available platforms, see the BlackBerry Dynamics SDK Documentation.

The BlackBerry Dynamics SDK provides a powerful set of tools to ISV and enterprise developers. It allows developers to focus on building commercial and business apps rather than learning how to secure, deploy, and manage those apps. The BlackBerry Dynamics Platform includes:

  • Lifecycle management
  • Security and compliance policies
  • Secure connectivity to enterprise services
  • Secure storage
  • Secure inter-app communication
  • Application configuration and application specific policies

The BlackBerry Dynamics platform supports common business operating systems, mobile, and desktop, including iOS, Android, macOS and Windows.

The simplest way to understand the BlackBerry Dynamics platform is to think of it as three key components: the BlackBerry Dynamics SDK and BlackBerry servers (BlackBerry UEM) connected by a Network Operations Center (NOC). BlackBerry Dynamics provides the services and architecture to build, securely deploy, and manage apps. BlackBerry UEM includes the BlackBerry Dynamics Secure Mobility Platform and delivers the Enterprise Mobility Management (EMM) solution to securely manage devices.

With the acquisition of Good Technology by BlackBerry, BlackBerry has created a unified product with best-in-class Bring Your Own Device (BYOD), EMM, and Mobile Device Management (MDM) capabilities.

 

BlackBerry Dynamics Secure Mobility Platform

The BlackBerry Dynamics (BD) platform consists of BD Runtime, the BD Network Operation Center (NOC), and BD servers.

The BD Runtime is included in every BD mobile app. The runtime has an API that gives the app access to activation, user authentication, secure storage, communication behind the firewall, and much more, all while enforcing security policies on behalf of the organization. To work with the BD Runtime, you need to download the BlackBerry Dynamics SDK for target platform (iOS, Android, Windows, macOS). BlackBerry also offers plug-in support for cross platform technologies such as Apache Cordova, HTML5, and Xamarin.

By including the BlackBerry Dynamics SDK in your app, you will have access to app policies, inter-app communication, secure storage, secure channel push, shared services, authentication delegation, Single Sign-on (KCD and GD auth Tokens), user and app config information, and much more.

BlackBerry UEM

BlackBerry UEM is the server component that brings everything together. It merges the best-in-class BYOD functionality of BlackBerry Dynamics with the best-in-class EMM (including MDM) solution. Administrators use UEM to manage users, groups, policies, apps, app configurations, and more.

The BlackBerry NOC enables secure communication between your BD Runtime app and the BlackBerry Proxy. The NOC also verifies the validity of user and access keys before data touches your enterprise, in addition to supporting the secure push infrastructure from server-side apps to BD Runtime apps.

UEM, Good Control (GC), and BlackBerry Proxy servers are included in the EMM solution. They provide various services to users, devices and apps.

For app developers, you get:

  • Security and compliance policies
  • Secure connectivity to enterprise services
  • App configuration
  • App policies
  • Secure storage on-device
  • Wipe and lock functionality
  • Secure inter-app communication
  • Application lifecycle management

BlackBerry Enterprise Mobility Server (BEMS)

The BlackBerry Dynamics platform offers enterprise mBaaS (Mobile Backend as a Service) capabilities. Many of these mBaaS services are implemented in the BlackBerry Enterprise Mobility Server (BEMS). BEMS provides programmatic connectivity through standardized APIs to enterprise systems including Microsoft SharePoint, Microsoft Lync, Microsoft Exchange, Cisco Jabber, Active Directory and more. BEMS provides APIs to invoke services such as push notifications, directory lookups, key value store, document access, IM, and presence. Developers can add these services to apps without having extensive knowledge of how to configure or connect to specific back-end systems of records.

These high quality enterprise back-end services are leveraged by BlackBerry Work, BlackBerry Connect, and other BlackBerry Secured apps. ISV and custom BlackBerry Secured apps can also make use of these services.

The BlackBerry Dynamics Platform provides a range of SDKs and plug-ins, allowing developers to work in familiar environments to build native, hybrid, and web apps. Once apps are built, developers can assume the role of an IT admin to quickly validate the management and distribution of their apps through the BlackBerry Dynamics Platform.

The BlackBerry Dynamics SDK is available natively to all major platforms and development technologies including:

  • iOS
  • Android
  • Windows
  • macOS

In addition, BlackBerry supports cross-platform development frameworks via dedicated BlackBerry Dynamics SDKs for:

  • Cordova/PhoneGap
  • HTML5 web apps
  • Xamarin

Security Services

Security Services allow you to address security concerns about making sensitive company information available on mobile devices. You can ensure that the content that is stored on devices, exchanged with resources behind the corporate firewall, or shared between BlackBerry-secured apps is always encrypted. Since the platform uses government-grade device-independent crypto libraries, content is always encrypted. The BlackBerry Dynamics SDK includes support for the following security services:

  • Identity & Authorization APIs
  • Secure Storage APIs
  • Secure Communications APIs
  • Secure Inter-App Data Exchange APIs

Mobile Services

Mobile Services allow you to create engaging apps that will improve user productivity. You can reduce development time by using existing services -- no more building everything from scratch! And because the BlackBerry Dynamics Platform is the foundation for all services, government-grade encryption ensures end-to-end security. The BlackBerry Dynamics SDK includes support for the following mobile services:

  • Presence Service
  • Send Email Service
  • Transfer Files Service
  • Push Service
  • Directory Lookup Service
  • Docs Service
  • Launch Service

Platform Services

Platform Services make it easy to integrate apps with enterprise infrastructure (e.g., Active Directory, SharePoint, Exchange, Office 365, Lync). Focus on creating innovative apps without worrying about programming for the back-end, server maintenance, or deploying complex infrastructure. Single sign-on, horizontal scaling, HA/DR, VPN-less access to the intranet -- simply building on the current version of the BlackBerry Dynamics Platform enables it all. The BlackBerry Dynamics SDK includes support for the following mobile services:

  • Identity & Access Management
  • Single Sign-on Authentication
  • Reliable App Deployment at Scale
  • Secure Access to Corporate Data
  • App-Level Controls for IT

Prerequisites

  • Mac OS 10.9.4 or later
  • Xcode 9.0 and iOS SDK 9.0 or later
  • BlackBerry Dynamics SDK for iOS
  • Internet connection

Download, install & configure the BlackBerry Dynamics SDK for iOS

  1. Download the SDK.

You will be prompted to log in with your BlackBerry Online Account. If you don't have an account, click the "Sign up" link to create one for free.

  1. Extract the file from the download package.
  2. Double-click the .pkg file to install the SDK.

Prerequisites

  • Android Studio
  • Internet connection

Download, install & configure the BlackBerry Dynamics SDK for Android

It is recommended that you install the BlackBerry Dynamics SDK for Android using the Android SDK Manager. If you are unable to use the Android SDK Manager, you can install the SDK manually.

  1. Click Tools > Android > SDK Manager.
  2. Click the SDK Update Sites tab. 
  3. Click Add.
  4. Create a new update site with the following information:
    • Name: BlackBerry Dynamics SDK
    • URL: https://global.blackberry.com/en/sdk/android/addon.xml
  5. Click OK.
  6. Click the SDK Tools tab.
  7. Select the BlackBerry Dynamics Sdk check box.
  8. Click Apply.
  9. Click OK when prompted to install the SDK.
  10. Accept the license agreement and click Next.
  11. Click Finish once the installation is complete.

The BlackBerry Dynamics SDK is now ready to use in your Android projects.

Note: In the BlackBerry Dynamics SDK version 4.0 and later, there is a change to the extracted folder structure in the extras/blackberry/dynamics_sdk folder. At this level there is now an m2repository/ folder for .aar distribution, and an sdk/ folder that contains the original .jar distribution and resources. If you are updating the SDK to version 4.0 or later, you must edit your settings.gradle files as necessary to account for the extra sdk/ folder at this level.

  1. Visit the Downloads page to download the SDK for Android. 
  2. Open your Android home directory in a file manager app or change to the directory in a terminal window. This is the directory named sdk and should be in the following locations, which may be hidden by default.
    • Windows: C:\Users\[username]\AppData\Local\Android
    • Mac: /Users/[username]/Library/Android/sdk
  3. Navigate from this directory to the extras sub-directory.
  4. Navigate to the blackberry sub-directory. If there isn’t already a sub-directory named blackberry, create it and navigate to it.
  5. If there is already a directory named dynamics_sdk here, then you may already have an installation of the BD SDK for Android. You can move or delete the current directory, or use a different name for the new directory.
  6. Copy the BD SDK for Android zip file into the blackberry directory and extract its files, or extract the files here directly. This will create a directory structure with a directory named sdk as its root.
  7. Rename the new sdk directory to dynamics_sdk

The BlackBerry Dynamics SDK is now ready to use in your Android projects.

Compatibility

  • Xcode 9.2
  • Apache Cordova version 7.0.1
  • Node.js version 6.11.4
  • macOS Sierra

Set up the BlackBerry Dynamics SDK for iOS

Before continuing, you must set up your environment for iOS development. Please select the iOS platform above to view the setup requirements and instructions for an iOS environment.

Download the BlackBerry Dynamics plug-ins

  1. Download the BlackBerry Dynamics Plugins for Cordova.
  2. Extract the .ZIP file to your desired location.

Compatibility

  • Android Studio version 3.0.1
  • Apache Cordova version 7.0.1
  • Node.js version 6.11.4
  • macOS Sierra

Set up the BlackBerry Dynamics SDK for Android

Before continuing, you must have your environment setup for Android development. Please select the Android platform above to view the setup requirements and instructions for an Android environment.

Download the BlackBerry Dynamics plug-ins

  1. Download the BlackBerry Dynamics Plugins for Cordova.
  2. Extract the .ZIP file into your desired location.

Develop a BlackBerry Secured App for iOS using Apache Cordova

We’ll be using the standard Cordova CLI to execute all commands. Please refer to the official Apache Cordova v7.x Documentation for more information.

1. Open your favorite Terminal program.

2. Create a new Cordova project.

$ cordova create HelloBBD com.company.appname

3. Change to the project folder.

$ cd HelloBBD

4. Add platforms.

$ cordova platform add ios

5. Add the configure plugin.

Note: The cordova-plugin-bbd-configure plugin will try to generate paths to the SDKs for Android and iOS. If you have trouble with the auto-discovery feature, or have multiple BBD SDK versions installed, you may wish to manually specify the paths to the applicable SDK(s). Please see the README.md file in the cordova-plugin-bbd-base plugin folder for advanced usage. If you are only developing for iOS, use the --variable ignoreFailure="true" flag with the command.

$ cordova plugin add <path to sdk>/plugins/cordova-plugin-bbd-configure -variable

6. Add BlackBerry Dynamics plug-ins. At a minimum, you must add the base plug-in if you want to secure your application with BlackBerry Dynamics.

$ cordova plugin add <path-to-bbd-cordova-plugins>/cordova-plugin-bbd-all

7. Optionally, install the ios-deploy package if you want to install iOS apps from the Cordova command-line.

$ sudo npm install –g ios-deploy

  • If your macOS is v10.11 or greater, you will likely need to run the following command instead (refer to the ios-deploy GitHub repo for more detailed usage instructions: https://github.com/phonegap/ios-deploy:

$ sudo npm install –g ios-deploy --unsafe-perm=true

8. Prepare the project.

$ cordova prepare 

You may receive a Cordova build error stating that "Code signing is required for product type 'Application' in SDK 'iOS 11.0'". If so, to continue you must:

  • Open the project in Xcode
  • Configure application signing and choose a Team

9. Build the application in Terminal (or Xcode).

$ cordova build ios

You have now successfully built a BlackBerry Dynamics enabled app for iOS!

We’ll be using the standard Cordova CLI to execute all commands. Please refer to the official Apache Cordova v7.x Documentation for more information.

1. Open your favorite Terminal program.

2. Change to your existing projects folder.

$ cd <MyApp>

3. Add the configure plugin.

$ cordova plugin add <path to sdk>/plugins/cordova-plugin-bbd-configure –variable

Note: The cordova-plugin-bbd-configure plugin will try to generate paths to the SDKs for Android and iOS. If you have trouble with the auto-discovery feature, or have multiple BBD SDK versions installed, you may wish to manually specify the paths to the applicable SDK(s). Please see the README.md file in the cordova-plugin-bbd-base plugin folder for advanced usage. If you are only developing for iOS, use the --variable ignoreFailure="true" flag with the above command.

4. Add BlackBerry Dynamics plug-ins. At a minimum, you must add the base plug-in if you want to secure your application with BlackBerry Dynamics.

$ cordova plugin add <path-to-bbd-cordova-plugins>/cordova-plugin-bbd-all

5. Build the application.

$ cordova build ios

Develop a BlackBerry Secured App for Android using Apache Cordova

We’ll be using the standard Cordova CLI to execute all commands. Please refer to the official Apache Cordova v7.x Documentation for more information.

1. Open your favorite Terminal program.

2. Create a new Cordova project.

$ cordova create HelloBBD com.company.appName

3. Change to the project folder.

$ cd HelloBBD

4. Add platforms.

$ cordova platform add android

5. Add the configure plugin. 

$ cordova plugin add <path to sdk>/plugins/cordova-plugin-bbd-configure --variable bbdSDKForAndroid='/Users/<your user folder>/Library/Android/sdk/extras/blackberry/dynamics_sdk'

Note: There is a known issue that affects the configure plugins ability to automatically locate the Android Native SDK in some cases. If auto discovery is failing for you, as a temporary workaround, provide the path explicitly as described.

6. Add the BlackBerry Dynamics plugins. At a minimum, you must add the base plugin if you want to secure your application with BlackBerry Dynamics.

$ cordova plugin add <path-to-bbd-cordova-plugins>/cordova-plugin-bbd-all

7. Build the project.

$ cordova build

You have now successfully built a BlackBerry Dynamics enabled app for Android!

We’ll be using the standard Cordova CLI to execute all commands. Please refer to the official Apache Cordova v7.x Documentation for more information.

1. Open your favorite Terminal program.

2. Change to your existing projects folder.

$ cd <MyApp>

3. Add the configure plugin.

$ cordova plugin add <path to sdk>/plugins/cordova-plugin-bbd-configure --variable bbdSDKForAndroid='/Users/<your user folder>/Library/Android/sdk/extras/blackberry/dynamics_sdk'

Note: There is a known issue which affects the configure plugins ability to automatically locate the Android Native SDK in some cases. If auto discovery is failing for you, as a temporary workaround, provide the path explicitly as described.

4. Add BlackBerry Dynamics plugins. At a minimum, you must add the base plugin if you want to secure your application with BlackBerry Dynamics.

$ cordova plugin add <path-to-bbd-cordova-plugins>/cordova-plugin-bbd-all

5. Build the project.

$ cordova build

You have now successfully updated a BlackBerry Dynamics enabled app for Android!

 

Develop a BlackBerry Secured App for Android

It is recommended that you build your app after each section in this process. This will allow you to confirm each step and will make debugging problems easier.

The BlackBerry Dynamics SDK contains a skeleton template project that you can use to create a new Android app. Create a copy of the Skeleton directory that you will use for your app. The Skeleton project is located in a sub-directory of your Android home directory with the following path: sdk/extras/blackberry/dynamics_sdk/sdk/samples/Skeleton/

By default, the Android home directory is located here:

  • Windows: C:\Users\[username]\AppData\Local\ Android
  • Mac: /Users/[username]/Library/Android/sdk

Open the copy that you just created in Android Studio (File > Open).

The settings.json file is located within the assets folder of your project. It is used by the BlackBerry Dynamics (BD) Runtime to read configuration information about your app, such as the GD library mode, GD entitlement app ID and BD app version. Open the settings.json file and update the GDLibraryMode, GDApplicationID and GDApplicationVersion using the guidelines below:

GDLibraryMode: Can be set to either GDEnterpriseSimulation or GDEnterprise.

  • Use GDEnterpriseSimulation if you do not have a BlackBerry UEM Server, Good Control server, or a Good Control Cloud account and you are using an Android emulator.
  • Use GDEnterprise to test with a BlackBerry UEM Server, Good Control server, or Good Control Cloud for production deployments.

A connection to the BlackBerry Dynamics Network Operation Center (NOC) is required for both options.

GDApplicationID: A unique identifier for your app, which should be the same across all platforms (i.e. Android, iOS, etc.). This value is similar to the app package name. No capital letters or spaces are allowed. This value is also registered in the UEM or Good Control server.

GDApplicationVersion: This is a compatibility version for your BD enabled app. It should not match your app version, which can change more frequently. This should only be updated when compatibility related to BlackBerry Dynamics integration changes, such as when you add or remove BlackBerry Dynamics services in your app. Needlessly updating this to match your app version will result in additional work for both you and all administrators who have deployed your app.

Sample settings.json that uses Simulation Mode:

{
    "GDLibraryMode": " GDEnterpriseSimulation"",
    "GDApplicationID": "com.example.applicationname",
    "GDApplicationVersion": "1.0.0.0"
}

Sample settings.json that uses Enterprise Mode:

{
    "GDLibraryMode": "GDEnterprise",
    "GDApplicationID": "com.example.applicationname",
    "GDApplicationVersion": "1.0.0.0"
}

It is best practice to add the GDapplicationVersion to the AndroidManifest.xml file as well as to the settings.json. file. Add it in the application item, in a meta-data tag with attributes as shown:

<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <meta-data android:name="GDApplicationVersion" android:value ="1.0.0.0" />

 

The Skeleton project is called Skeleton. Skeleton is also used in the package and class names. It is recommended that you modify these names to something appropriate for your app. To modify, from the Project tab of Android Studio, right-click on the object to rename and choose Refactor > Rename.

You can now deploy and test your app, and can explore development with additional BlackBerry Dynamics APIs. Advance to the next steps to continue.

It is recommended that you build your app after each section in this process. This will allow you to confirm each step and will make debugging problems easier.

The settings.json file is created within your project. It is used by the BlackBerry Dynamics (BD) Runtime to read configuration information about your app, such as the GD library mode, GD entitlement app ID and BD app version.

  1. If you already have an assets folder in your project, skip to step #5. If not, proceed to step 2.
  2. In Android Studio, right-click the top-level Application package and New > Folder > Assets Folder. This opens a dialog that provides a confirmation for where to create a source root for assets.
  3. Leave the default options selected and click Finish.
  4. Expand the package in which you just created the folder. The assets folder should appear under the package.
  5. Right-click the assets folder and click New > File.
  6. Enter settings.json as the file name and click OK.
  7. Use one of the following examples to build your own settings.json file. Modify the examples to include your own GDApplicationID and GDApplicationVersion.

GDLibraryMode: Can be set to either GDEnterpriseSimulation or GDEnterprise. Use GDEnterpriseSimulation if you do not have a BlackBerry UEM Server, Good Control server, or a Good Control Cloud account and are using an Android emulator. Use GDEnterprise to test with a BlackBerry UEM Server, Good Control server or Good Control Cloud for production deployments. A connection to the BlackBerry Dynamics Network Operation Center (NOC) is required for both options.

GDApplicationID – A unique identifier for your app, which should be the same across all platforms (i.e. Android, iOS, etc.). This value is similar to the app’s package name. No capital letters or spaces are allowed. This value is also registered in the UEM or Good Control server.

GDApplicationVersion – This is a compatibility version for your BD enabled app. It should not match your app version, which can change more frequently. This should only be updated when compatibility related to BlackBerry Dynamics integration changes, such as when you add or remove BlackBerry Dynamics services in your app. Needlessly updating this to match your app version will result in additional work for both you and the administrators who have deployed your app.

Sample settings.json that uses Simulation Mode:

{
    "GDLibraryMode": " GDEnterpriseSimulation"",
    "GDApplicationID": "com.example.applicationname",
    "GDApplicationVersion": "1.0.0.0"
}

Sample settings.json that uses Enterprise Mode:

{
    "GDLibraryMode": "GDEnterprise",
    "GDApplicationID": "com.example.applicationname",
    "GDApplicationVersion": "1.0.0.0"
}

Start by linking the BD Runtime into the app. The BD Runtime will be added as a module. This requires change in several parts of the project.

  1. BlackBerry Dynamics does not support right-to-left (RTL) layouts. This may require a change to your manifest file.  Open AndroidManifest.xml in Android Studio and ensure  supportsRtl is set to false as shown below.

    android:supportsRtl="false"

  2. If your application supports Android back-up, add the following line within the application tag of your AndroidManifest.xml.  We recommend adding this line under the “allowBackup” parameter, which is set to true if your application supports back up.

    android:fullBackupContent="@xml/gd_backup_scheme"

 

  1. Open the build.gradle for your project.
  2. Within allprojects, locate the repositories section.
  3. Add reference to the BD SDK AAR file as shown below.

    def localProperties = new File(rootDir, "local.properties")
    Properties properties = new Properties()
    localProperties.withInputStream { instr ->
        properties.load(instr)
    }
    def sdkDir = properties.getProperty('sdk.dir')
    maven { url sdkDir+'/extras/blackberry/dynamics_sdk/m2repository' }

    The allprojects section should now look similar to this the code below. Note that this sample assumes the BD SDK was installed to the default location. If you installed to a different location you will need to update the path in the url.

    allprojects {
        repositories {
            google()
            jcenter()

            def localProperties = new File(rootDir, "local.properties")
            Properties properties = new Properties()
            localProperties.withInputStream { instr ->
                properties.load(instr)
            }
            def sdkDir = properties.getProperty('sdk.dir')
            maven { url sdkDir+'/extras/blackberry/dynamics_sdk/m2repository' }
        }
    }

  1. Open the build.grade file for module app.
  2. Add the following lines within the dependencies of your app:

    implementation 'com.blackberry.blackberrydynamics:android_handheld_platform:+'
    implementation 'com.blackberry.blackberrydynamics:android_handheld_backup_support:+'


    Note: Depending on your application’s needs, you may need to add further dependancies here.  For example, if your application supports wearables, you will need to specify the appropriate BlackBerry Dynamics dependancies.  For a full list of refer to the BlackBerry Dynamics Development Guide.


  3. Press “Sync Now”, shown in the upper right of Android Studio.

The BD Runtime is now linked to the handheld app and you are ready to start making code changes to your app to integrate with the BD Runtime.

Establishing a connection to the BlackBerry Dynamics (BD) platform requires authorization of the end user and the app. Either of the following method calls can be used to initiate both authorizations:

  • Call authorize, which is direct initiation.
  • Call activityInit, which is indirect initiation.

An app can use only direct or indirect authorization initiation, not both. Both mechanisms each require different implementations in the app code. The mechanisms also place different restrictions on classes in the app user interface.

Authorization generally includes establishing a data connection to the UEM or BD proxy infrastructure and to the enterprise that provisioned the end user. In addition, authorization will also include any necessary registration of the device, at the BlackBerry Dynamics Network Operation Center (infrastructure activation), and at the enterprise (enterprise activation).

Authorization may include user interaction. All user interaction that is part of authorization takes place in a user interface that is part of the BD Runtime library, not part of the app.

The authorization API is state-based and asynchronous. The initiation method generally returns immediately. Success or failure of authorization is then notified to the app code later, as a transition of the authorization state. The app should generally wait to be notified of transition to the authorized state before attempting to utilize any other BlackBerry Dynamics APIs.

The following snippet shows indirect initiation of BlackBerry Dynamics authorization processing, and implicit setting of the authorization state transition observer:

public class MyActivity extends Activity implements GDStateListener {

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GDAndroid.getInstance().activityInit(this);
    // rest of Activity initialization ...
    }

    //GDStateListener method implementations         
    public void onAuthorized()     {
        //Fictional example method calls below.
        startSecureDBAccess();
        startAppComms();
    }
    // Additional GDStateListener methods…
}

The MyActivity instance is implicitly its own authorization state transition observer. This is implemented by the declaration that the MyActivity class extends the GDStateListener interface.

Connection to the GD platform is initiated by calling activityInit in the onCreate method. This code would also be present in all the other activity classes in the app.

The principal processing of the activity, represented by the startSecureDBAccess and startAppComms calls, only proceeds when authorization processing is complete. This is implemented by placing the calls in the onAuthorized callback.

The following snippet shows direct initiation of BlackBerry Dynamics authorization processing:

public class LaunchActivity extends Activity {
    private boolean_authorizeCalled = false;
    // Override annotation should go here
    public void onResume() {
        super.onResume();
        if (!_authorizeCalled) {
            GDAndroid.getInstance.authorize( MyGDAppEventListener. sharedInstance());_authorizeCalled = true;
        }
        // Rest of activity initialization here, no use of BlackBerry Dynamics APIs.
    }
    // rest of class code here.
}

The private variable_authorizeCalled is used to ensure that authorize() is called only once.

The singleton MyGDAppEventListener object is set as the GD event handler.

The event handler would receive all GDAppEvent objects dispatched from the BD Runtime, which would include an event with type GDAppEventAuthorized when the end user is first authorized. After receiving that event, the app could make full use of all BlackBerry Dynamics APIs.

You can now deploy and test your app, and can explore development with additional BlackBerry Dynamics APIs. Advance to the next steps to continue.

Develop a BlackBerry Secured App for iOS

After installing the BlackBerry Dynamics SDK for iOS, use the BlackBerry Dynamics template to create a new app. This template includes a single view controller, a storyboard (or nib) file, and all of the necessary frameworks and compile time directives.

1. Start Xcode.

2. Select New > Project.

3. On the splash screen, select BlackBerry Dynamics

4. Enter project information and set the language to Objective-C or Swift.

5. All necessary frameworks and artifacts have been included.

 

6. Open Info.plist file in the project and change GDApplicationID to your own:

GDApplicationID

  • The general form is com.yourcompany.application_name (only lower case, no spaces, and must not begin with com.good).
  • The same id can be used for multiple apps on different platforms, such as iOS and Android, therefore it is recommended to avoid including the platform specific information (example: com.yourcompany.good_application_for_ios).


GDApplicationVersion

  • A version number is four parts. Use 1.0.0.0 for the first BlackBerry Dynamics-enabled app.
  • It is not recommended to change the version often, unless required to provide different access to specific users, or to differentiate a new app from existing versions of the app due to newly added services.

7. On the General tab, remove the static setting for Main Interface.

8. Launch the main UI after the app is authorized.

All BD apps must be successfully authorized prior to launching the app’s main interface. Creating a BD skeleton app using the Xcode BlackBerry Dynamics template includes the required BD authorization functions, as well as BD event handling functions. 

Check out the AppDelegate.h and AppDelegate.m files for those functions. You will notice that the app authorization functions are called first in the didFinishLaunchingWithOptions

Once the app is authorized successfully, then you should programmatically load the app’s main interface in the code below.

Objective-C

  
    - (void)onAuthorized:(GDAppEvent *)anEvent {
    switch (anEvent.code) {
        case GDErrorNone: {
            if (!started) {
                  
               // launch application UI here
               
               started = YES;
            }
            break;
        }
        default:
            NSAssert(false, @"Authorized startup with an error");
            break;
    }
}
  

Swift

  
    func onAuthorized(anEvent:GDAppEvent ) {
    switch anEvent.code {
        case .errorNone:
            if !self.started {
                    
// launch application UI here
              
self.started = true
            }
        default:
            assert(false, "Authorized startup with an error")
            break
        }
}


  

 

9. Add a Label object to Main.storyboard and set its text to Welcome to BlackBerry Dynamics Development!

10. Save the project. Your app is ready to compile and build. 

The BlackBerry Dynamics skeleton app created using the BlackBerry Dynamics template does not contain any app specific code. When running the app, it will display the text set for the Label earlier.

In order to run and test your BD app, you will need to set up the BlackBerry Dynamics servers. Alternatively, if you don’t have the BlackBerry Dynamics environment set up, Enterprise Simulation Mode can be used to test your BD app, as it enables you test without connecting to the BlackBerry Dynamics servers.

In Enterprise Simulation Mode, there is no user authentication at the enterprise level, so there will be no communication through the enterprise firewall. If your app requires a connection behind the firewall, using the Enterprise Simulation Mode to test your BD app is not recommended. You will need to set up BlackBerry UEM or Good Control to test the app on a device.

Important: Enterprise Simulation Mode is not intended for a production environment.

To enable the Enterprise Simulation Mode for your BD app, add the following to your app's Info.plist file:

Key: GDLibraryMode
Type: String (default)
Value: GDEnterpriseSimulation

You are now ready to build and run your BD app in iOS Simulator.

When your app is running for the first time on the iOS Simulator, you will be prompted to activate the app. In Enterprise Simulation Mode, you can enter any email address and any 15-character access key to complete the activation process. The app will go through the enterprise activation process. Once the app has been activated, you’ll be prompted to create a password to access the app.

The Password Requirements link at the bottom of the screen provides guidance on the required password complexity. Password complexity is controlled via policies managed by your IT admin through the BlackBerry UEM or Good Control administration console.

If you already have an existing iOS app, you can configure the app to integrate with the BlackBerry Dynamics SDK.

1. Start Xcode.

2. Open the Xcode Project of your existing app.

3. Open the Build Phases tab and expand Link Binary With Libraries section.

4. Add the following required frameworks and libraries:

  • AdSupport.framework
  • CFNetwork.framework
  • CoreData.framework
  • CoreTelephony.framework
  • GD.framework
  • libz.dylib or libz.tbd
  • LocalAuthentication.framework
  • MessageUI.framework
  • MobileCoreServices.framework
  • Quartzcore.framework
  • QuickLook.framework
  • Security.framework
  • SystemConfiguration.framework

5. Configure use of the BlackBerry Dynamics SDK loader: 

  • Create a new file named default.xcconfig in the project directory and enter the following settings in the file: 

FIPS_PACKAGE=$(CURRENT_ARCH).sdk
LDPLUSPLUS=~/Library/Application
Support/BlackBerry/Good.platform/iOS/FIPS_module/$FIPS_PACKAGE/bin/GD_fipsld
LD=~/Library/Application Support/BlackBerry/Good.platform/iOS/FIPS_module/$FIPS_PACKAGE/bin/GD_fipsld
ENABLE_BITCODE=NO

  • If you installed the BlackBerry Dynamics SDK for iOS in a location other than the default, change the initial part of the LDPLUSPLUS and LD settings in the file to your install path. 
  • In your project build settings Configurations, make sure the Debug or other build configs point to the default.xcconfig file. 
  • Ensure that the target is set to iOS 9 or higher. 
  • Make sure that the all_load linker option is not specified. Check the Other Linker Flags field in the target build settings and remove this flag. Alternatively, you can use the ObjC linker flag. 

6. Add GDAssets.bundle to the project.

  • Right-click on the GD.framework and select GD.framework > Resources > Show in Finder.
  • Drag and drop the GDAssets.bundle to the project.
  • Choose Create folder references when prompted for options for adding the files.

7. Set the BlackBerry Dynamics Application ID and Version in the app's Info.plist.

GDApplicationID

  • The general form is com.yourcompany.application_name (only lower case, no spaces, and must not begin with com.good).
  • The same id can be used for multiple apps on different platforms such as iOS and Android. It’s recommended to avoid including the platform specific information (example: com.yourcompany.good_application_for_ios).

GDApplicationVersion

  • A version number is four parts. Use 1.0.0.0 for the first BD-enabled app.
  • It is not recommended to change the version often unless it’s required to provide different access to specific users, or to differentiate a new app from existing versions of the app due to newly added services.

8. Add a variable reference in the URL scheme and URL identifier specifiers.

9. Save the project.

To work as a BD app, the app must use GDiOSDelegate, and the launch code execution must be delayed until the end user has been authorized with following the process:

  1. Import GDiOS.h and implement a GDiOSDelegate protocol. Then set the app’s window to be a GD window.
  2. Use GDAppEvent to process BD authorization events.
  3. Switch off automatic loading of the main storyboard. Instead, load the main storyboard programmatically when the end user has been authorized.
  4. Move the app launch code from the didFinishLaunchingWithOptions to GDAppEvent handler method and call the new function when the main storyboard has finished loading.

Follow the steps below to integrate your existing iOS app with the BlackBerry Dynamics Platform:

1. Start Xcode.

2. Open the Xcode Project of your existing app.

3. Create new GDiOSDelegate class files. The GDiOSDelegate class name used in this process will be GDAppGDiOSDelegate.h and AppGDiOSDelegate.m

  • Go to New > File > iOS > Cocoa Touch Class and add AppGDiOSDelegate. Put the subclass as NSObject.

4. Open the file AppGDiOSDelegate.h and add #import <GD/GDiOS.h>

5. Add the GDiOSDelegate protocol.

6. Declare the GDiOSDelegate class as having a static function sharedInstance that returns an instance of itself.

7. Add the property BOOL hasAuthorized as a flag to keep the status of the BD authorization.

8. Add the property AppDelegate *appDelegate for a reference to an instance of the app delegate.

9. Add the property RootViewController *rootViewController to get a reference to the app’s main interface. 

The AppGDiOSDelegate.m file should look like this:

#import <Foundation/Foundation.h>
#import <GD/GDiOS.h>
#import "RootViewController.h"
#import "AppDelegate.h"

@interface AppGDiOSDelegate : NSObject <GDiOSDelegate>

@property (weak, nonatomic) RootViewController *rootViewController;

@property (weak, nonatomic) AppDelegate *appDelegate;

@property (assign, nonatomic, readonly) BOOL hasAuthorized;

+(AppGDiOSDelegate *)sharedInstance;

@end

10. Open the AppGDiOSDelegate.m file. Add the following import statements:

#import <GD/GDiOS.h>
#import "AppGDiOSDelegate.h"
#import "RootViewController.h"
#import "AppDelegate.h"

11. Override the read-only property hasAuthorized to be writeable internally:

@property(assign, nonatomic) BOOL hasAuthorized;

12. Add static initializer code, including an init function that is declared as private and a sharedInstance implementation that guarantees that only one instance is ever created:

+(instancetype)sharedInstance
{
        static AppGDiOSDelegate *appGDiOSDelegate = nil;
        static dispatch_once_t onceToken = 0;
        dispatch_once(&onceToken, ^{
            appGDiOSDelegate = [[AppGDiOSDelegate alloc] init]; });
        return appGDiOSDelegate;
}

-(instancetype)init
{
        self = [super init];
        return self;
}

13. Add custom setters for the view controller and app delegate properties that call the new function, as well as setting the property values:

-(void)setRootViewController:(RootViewController *)rootViewController
{
        _rootViewController = rootViewController;
        [self didAuthorize];
}

-(void)setAppDelegate:(AppDelegate *)appDelegate
{
        _appDelegate = appDelegate;
        [self didAuthorize];
}

14. Add a new private method didAuthorize that checks whether the end user has been authorized, checks that properties for the view controller and app delegate have been set, and then calls the app delegate didAuthorize function if all those conditions are met:

-(void)didAuthorize
{
        if (self.hasAuthorized && self.rootViewController && self.appDelegate){
        [self.appDelegate didAuthorize];
        }
}

15. Add a dummy for the required GDiOSDelegate functions:

-(void)handleEvent:(GDAppEvent *)anEvent { }

16. Ensure the AppGDiOSDelegate.m file is as such:
#import <Foundation/Foundation.h>
#import <D/GDiOS.h>
#import "AppGDiOSDelegate.h"
#import "RootViewController.h"
#import "AppDelegate.h"

@interface AppGDiOSDelegate()

@property(assign, nonatomic) BOOL hasAuthorized;

-(instancetype)init;
-(void)didAuthorize;

@end

@implementation AppGDiOSDelegate

+(instancetype)sharedInstance
{
        static AppGDiOSDelegate *appGDiOSDelegate = nil;
        static dispatch_once_t onceToken = 0;
        dispatch_once(&onceToken, ^{
                appGDiOSDelegate = [[AppGDiOSDelegate alloc] init]; });
        return appGDiOSDelegate;
}

-(instancetype)init
{
        self = [super init];
        return self;
}

-(void)setRootViewController:(RootViewController *)rootViewController
{
        _rootViewController = rootViewController;
        [self didAuthorize];
}

-(void)setAppDelegate:(AppDelegate *)appDelegate
{
        _appDelegate = appDelegate;
        [self didAuthorize];
}

-(void)didAuthorize
{
        if (self.hasAuthorized && self.rootViewController && self.appDelegate){
        [self.appDelegate didAuthorize];
        }
}

-(void)handleEvent:(GDAppEvent *)anEvent { }

@end

Follow the steps below to integrate your existing Swift app with the BlackBerry Dynamics SDK:

1. Start Xcode.

2. Open the Xcode Project of your existing app.

3. In the AppDelegate.swift, import the GD library. 

import GD.Runtime

4. Copy the two variables below and add them to your App Delegate class in the AppDelegate.swift file.

class AppDelegate : UIResponder , UIApplicationDelegate,  GDiOSDelegate {
    var window: UIWindow?
    var good: GDiOS?
    var started: Bool = false

5. Modify the didFinishLaunchingWithOptions method to implement GDiOSDelegate.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool 
{
  // Call BlackBerry Dynamics to authorise the app
   self.window = GDiOS.sharedInstance().getWindow()
   self.good = GDiOS.sharedInstance()
         
   self.good!.delegate = self
   self.started = false
       
  // Show the Good Authentication UI.
   self.good!.authorize()
         
  return true
}

1. Open the app’s info.plist

Make a note of the value of the key UIMainStoryboardFile and delete the key and value. You can also do this on the General tab. This value will be programmatically added after a successful BD authorization. 

2. Open the AppGDiOSDelegate.m file. To handle the BD authorization events, add the following functions:

  • handleEvent
  • onNotAuthorized
  • onAuthorized

Note the code under the case GDErrorNone: in the onAuthorized function. When there is no error during the authorization process, you will need to add the code to load the main storyboard, which you deleted from the property file. Add code to instantiate and launch the initial view controller. Add a call to the new didAuthorize function that was just added. See the code below:

-(void)handleEvent:(GDAppEvent *)anEvent {

    /* Called from _good when events occur, such as system startup. */
    switch (anEvent.type)
    {
        case GDAppEventAuthorized:
        {
            [self onAuthorized:anEvent];
            break;
        }
        case GDAppEventNotAuthorized:
        {
            [self onNotAuthorized:anEvent];
            break;
        }
        case GDAppEventRemoteSettingsUpdate:
        {
            //A change to application-related configuration or policy settings.
            break;
        }
        case GDAppEventServicesUpdate:
        {
            //A change to services-related configuration.
            break;
        }
        case GDAppEventPolicyUpdate:
        {
            //A change to one or more application-specific policy settings has been received.
            break;
        }
        case GDAppEventEntitlementsUpdate:
        {
            //A change to the entitlements data has been received.
            break;
        }

    }
}

- (void)onNotAuthorized:(GDAppEvent *)anEvent {

    /* Handle the Good Libraries not authorized event. */
    switch (anEvent.code)
    {
        case GDErrorActivationFailed:
        case GDErrorProvisioningFailed:
        case GDErrorPushConnectionTimeout:
        case GDErrorSecurityError:
        case GDErrorAppDenied:
        case GDErrorAppVersionNotEntitled:
        case GDErrorBlocked:
        case GDErrorWiped:
        case GDErrorRemoteLockout:
        case GDErrorPasswordChangeRequired:
        {
            // an condition has occured denying authorization, an application
                        // may wish to log these events
            NSLog(@"onNotAuthorized %@", anEvent.message);
            break;
        }
        case GDErrorIdleLockout:
        {
            // idle lockout is benign & informational
            break;
        }
        default:
            NSAssert(false, @"Unhandled not authorized event");
            break;
    }

}
- (void)onAuthorized:(GDAppEvent *)anEvent {
    /* Handle the Good Libraries authorized event. */
    switch (anEvent.code)
    {
        case GDErrorNone:
        {
            if (!self.hasAuthorized)
            {
                // launch application UI here
                self.hasAuthorized = YES;

                UIStoryboard *uiStoryboard =
                [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                                UIViewController *uiViewController =
                [uiStoryboard instantiateInitialViewController];

                self.appDelegate.window.rootViewController = uiViewController;

                [self didAuthorize];

            }
            break;
        }
        default:
            NSAssert(false, @"authorized startup with an error");
            break;
    }
}

3. Open the AppDelegate.m file, the original app delegate class. Add:

#import "AppGDiOSDelegate.h"
#import "RootViewController.h".

4. In didFinishLaunchingWithOptions, add the following calls:

[AppGDiOSDelegate sharedInstance].appDelegate = self;

self.window = [[GDiOS sharedInstance] getWindow];

[[GDiOS sharedInstance] authorize:[AppGDiOSDelegate sharedInstance]];

5. Save the app.

1. Open the app’s info.plist

Make a note of the value of the key UIMainStoryboardFile and delete the key and value. You can also do this on the General tab. This value will be programmatically added after a successful BD authorization. 

2. Open AppDelegate.swift. Add the following functions to handle authorization events.
func handle(_ anEvent: GDAppEvent) 
{     
    switch anEvent.type 
    {
            case .authorized:
                onAuthorized(anEvent: anEvent)
                break  
            case .notAuthorized:
                self.onNotAuthorized(anEvent: anEvent)
                break
            case .remoteSettingsUpdate:
               //A change to application-related configuration or policy settings.
                break
                
            case .servicesUpdate:
                //A change to services-related configuration.
                break
             case .policyUpdate:
                if started {
                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "AppPolicyUpdated"), object: nil)
                }
                break
            default:
                print("handleEvent \(anEvent.message)")
     }
}
    
func onNotAuthorized(anEvent:GDAppEvent ) 
{
    /* Handle the Good Libraries not authorized event. */
    switch anEvent.code 
    {
        case .errorActivationFailed: break
        case .errorProvisioningFailed: break
        case .errorPushConnectionTimeout: break
        case .errorSecurityError: break
        case .errorAppDenied: break
        case .errorAppVersionNotEntitled: break
        case .errorBlocked: break
        case .errorWiped: break
        case .errorRemoteLockout: break
        case .errorPasswordChangeRequired:
        // an condition has occured denying authorization, an application may wish to log these events
            print("onNotAuthorized \(anEvent.message)")
        case .errorIdleLockout:
            // idle lockout is benign & informational
            break

        default: assert(false, "Unhandled not authorized event");
     }
}
    
func onAuthorized(anEvent:GDAppEvent ) 
{
    /* Handle the Good Libraries authorized event. */
    switch anEvent.code 
    {
        case .errorNone:
            if !self.started 
     {
                //Show the User UI
                self.started = true
            }
        default:
            assert(false, "Authorized startup with an error")
            break
    }
}

 

1. Change the app user interface to be monitored and secured by the BD Runtime. Open the RootViewController.m file and add the following import statement:

#import "AppGDiOSDelegate.h".

2. In the viewDidLoad function, add an assignment of the new property in the static class to a reference to this instance of the view controller. In this example, it’s rootViewController.

[AppGDiOSDelegate sharedInstance].rootViewController = self;

3. Search the rootViewController assignment and replace with sharedInstance.

4. Move any original app launch code to the new didAuthorize function:

-(void)didAuthorize
{
//move your launch code to here...
    RootViewController *rootViewController = [AppGDiOSDelegate sharedInstance].rootViewController;
}

5. Save and compile the app.

  1. Move the original launch code to the new onAuthorized 

    func onAuthorized(anEvent:GDAppEvent ) 
    {
        /* Handle the Good Libraries authorized event. */
        switch anEvent.code 
        {
            case .errorNone:
                if !self.started 
                {
                    //Show the User UI
                    self.started = true
                   self.window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
                }
            default:
                assert(false, "Authorized startup with an error")
                break
        }
    }
  2. Save and compile the app.

To run and test your BD app, you will need to set up the BlackBerry Dynamics servers. If you don’t have the BlackBerry Dynamics environment set up, Enterprise Simulation Mode can be used to test your BD app, as it allows you test without connecting to the BlackBerry Dynamics servers.

In Enterprise Simulation Mode, there is no user authentication at the enterprise level, so there will be no communication through the enterprise firewall. If your app requires a connection behind the firewall, using the Enterprise Simulation Mode to test your BD app is not recommended. You will need to set up the BlackBerry UEM or Good Control servers to test the app on a device.

Important: Enterprise Simulation Mode is not intended for a production environment.

To enable Enterprise Simulation Mode for your BD app, add the following to the app's Info.plist file:

Key: GDLibraryMode
Type: String (default)
Value: GDEnterpriseSimulation

You are now ready to build and run your BD app in iOS Simulator.

When your app is running for the first time on the iOS simulator, you’ll be prompted to activate the app. In Enterprise Simulation Mode, you can enter any email address and any 15-character access key to complete the activation process. Once the app has been activated, you’ll be prompted to create a password to access the app.

The “Password Requirements” link at the bottom of the screen provides guidance on the required password complexity. Password complexity is controlled via policies managed by the IT admin through the BlackBerry UEM or Good Control administration console.

Deploy and Test Your BlackBerry Secured App

Deploy your BlackBerry Dynamics app to a smartphone, tablet, or emulator for testing purposes.

You require:

  • An Internet connection
  • A smartphone, tablet, or emulator supported by BlackBerry Dynamics
  • A BlackBerry UEM server or Good Control and Good Proxy server (option 2 below)

Although Enterprise Simulation Mode is not suitable for production deployment of your app, it is useful during development, and for verifying proper execution and behavior when migrating existing apps to BlackBerry Dynamics.

In simulation mode, a valid activation key is not required to open the app because there is no direct communication with BlackBerry Dynamics servers. Communication with the BlackBerry Dynamics NOC, however, continues to take place. In Enterprise Simulation Mode your BD apps are run on a device emulator.

To enable Enterprise Simulation Mode, whether you use an IDE or an outside text editor, you must change the following line in your app’s settings.json (Android) or or info.plist (iOS) file from:

"GDLibraryMode":"GDEnterprise"

to:

"GDLibraryMode":"GDEnterpriseSimulation"

Be sure to change it back when you are ready test the app with your BlackBerry UEM or BD enterprise servers or deploy it on a real device. When GDLibraryMode is set to GDEnterprise, default enterprise authentication is invoked to open the app.

On Android, the settings.json file is located in the ../assets/ folder of the app and must remain there. Communication with the BD Network Operations Center (NOC) still takes place during initial activation of the app, even in Enterprise Simulation mode. This means that the NOC must be accessible from the environment in which the app is running.

You will find that the app behaves differently than during standard enterprise execution in the following ways:

  • [Simulated] will appear in the BD Runtime user interface
  • Any email address and activation key (PIN) will be accepted for enterprise activation
  • No information is actually sent to BD enterprise servers, including the email address and activation key
  • The provisioning and policy setup flow is merely simulated in the UI
  • A hard-coded set of security and compliance policies will be in effect, authentication is not delegated
  • When run on a real device, not an emulator, the app will be wiped
  • Attempts to change the mode from GDEnterprise to GDEnterpriseSimulation for an app that is already installed on a device will result in the app being wiped
  • No lost-password recovery is available
  • Inter-container Communication (ICC) cannot be used, which means that the BD Services API cannot be used

Otherwise, the secure storage, secure communication, and push channel APIs are all available in Enterprise Simulation Mode. The communication APIs will not be able to connect to any enterprise app servers through the UEM or BD proxy infrastructure, although direct connections to enterprise app servers can still be made, if, for example, the AVD is running on a machine that is on the enterprise LAN or VPN.

A BlackBerry UEM server or BlackBerry UEM Cloud instance is required to perform testing on an actual smartphone or tablet.

Follow the required steps to configure a BlackBerry Secured app for testing in BlackBerry UEM. If you do not yet have a BlackBerry UEM server or BlackBerry UEM Cloud instance in place, refer to the Downloads section of this site for downloads and documentation. Alternatively, you can test using a Good Control server or Good Control Cloud account which is also described on that page.

Once the servers are in place, continue with the following steps:

  1. Log in to the BlackBerry UEM management console 
  2. Click Apps > New App > Internal BlackBerry Dynamics app entitlements > Next.
  3. Specify the BlackBerry Dynamics Entitlement ID and BlackBerry Dynamics Entitlement Version that was set in the app’s settings.json (Android) or info.plist (iOS) file. For example, com.blackberry. testApp and 1.0.0.0.  
  4. Click Add
    • Your application will be included in the list of available apps. If you need to provide additional configuration parameters for your app, such as whitelisting servers or configuring an app policy, select your app from the list and configure as necessary.

Recommendation: We recommend that you add the Android Package ID and Apple Bundle ID to your app’s configuration. This allows the use of easy activation, which avoids the requirement of entering an access key when first starting the app. This is also required if your app uses any BlackBerry AppKinetics services. To add these values:

  1. Click the app.
  2. On the iOS, OS X, and Android tabs, enter the appropriate values.
  3. Click Save.

After an app is registered in UEM, you can entitle users to install and use the app. You can entitle individual users or user groups. For production deployment, it’s recommended to use user groups. When developing or testing, you may wish to entitle an app to just one or two users. 

  1. Log in to the UEM management console. 
  2. Search for and select a user account.
  3. In the Apps section in the user profile, click +.
  4. Search for and select your app. Click Next.
  5. Leave the Disposition as optional (installation will not be forced) and select Assign. Now the application is assigned to the account you’ve selected.
  6. Depending on your authentication delegation configuration, you may need to generate an Access Key that will be used when the app is run for the first time after a fresh install. 

    To generate a new Access Key:
    • In the user's profile, under Activation details, click Set Activation Password
    • In the Activation option drop-down list, click BlackBerry Dynamics Access key generation.
    • Click Submit
    • The access key is emailed to the user. To view the access key, click on the key link above the Set activation password button. 
  7. Install the app from your IDE to your device using the standard method you use when testing an app. Then enter your email address and newly created access key when prompted after running your app for the first time.

A Good Control and Good Proxy server is required to perform testing on an actual smartphone or tablet. If you do not yet have a Good Control and Good Proxy server in place, refer to the downloads section of this site for downloads and documentation. Alternatively, you can test using a Good Control Cloud account which is also described on that page.

  1. Log in to the Good Control administration console.
  2. Click Manage Apps > Add App > BD app ID and Version only > Next

    By adding the BD app ID and Version only, you are not required to submit the binary app file (APK or IPA). Using this method also allows the app to be installed directly onto the device (from your IDE or side loaded). 

  3. Specify the GDapplicationID and GDapplicationVersion that was set in the app’s settings.json (Android) or info.plist (iOS) file. For example, com.blackberry. testApp and 1.0.0.0
  4. The app will now be included in the list of apps available on your server. If you need to provide additional configuration parameters for your app, such as whitelisting servers or configuring an app policy, select your app and configure as necessary.

Recommendation: We recommend you add the Android Package ID and Apple Bundle ID to your app’s configuration. This allows the use of easy activation, which avoids the requirement of entering an access key when first starting the app. To add these values:

  1. Click on your app.
  2. On the BlackBerry Dynamics tab, click EDIT.
  3. Specify the appropriate values.

After an app is registered in Good Control, you can entitle users to install and use the app. This can be done using individual users or with user groups. For production deployment, it’s recommended to use user groups. When developing or testing, you may wish to entitle an app to just one or two users.

  1. Log in to the Good Control management console.
  2. Click Users and Groups.
  3. Select a user account.
  4. Click User Actions > Edit User.
  5. On the APPS tab, click Add More.
  6. Select the app and click OK
  7. Depending on your authentication delegation configuration, you may need to generate an Access Key that will be used when the app is run for the first time after a fresh install. 

    To generate a new Access Key, on the ACCESS KEYS tab, click New Access Key. After it is created, the access key is shown in the list of provisioned access keys. 

  8. Install the app from your IDE on your device using the standard method you use when testing an app. Then enter your email address and newly created access key when prompted after running your app for the first time.

You may want to learn more about the BlackBerry Dynamics Plugins and how they work with your project. If you’ve built projects with Cordova plugins in the past, using the BlackBerry Dynamics plugins will be familiar to you.

Some features will automatically be available to your project after adding the cordova-plugin-bbd-base plugin such as FileSystem, XMLHttpRequest.

Generally, it’s recommended to use the cordova-plugin-bbd-all plugin to enable access to all BlackBerry Dynamics APIs. If more granular control is required, you can also install only the bare minimum of required plugins for your app.

A few items of note:

File System

This plugin overrides the default Cordova FileSystem object and provides access to the secure file system automatically upon installation of the cordova-plugin-bbd-base plugin.

HTTP

This plugin overrides the default XMLHttpRequest object automatically upon installation of the cordova-plugin-bbd-base plugin. Calls made via XHR will automatically route through the BlackBerry Dynamics Proxy.

When making HTTPS requests through an HTTP proxy, SSL/TLS certificate verification must be disabled. Certificate verification while using an HTTP proxy is not supported. BlackBerry Dynamics HTTP data communication does not go via the proxy specified in the device's native settings, if any.

The BlackBerry Dynamics Runtime supports Basic Access, Digest Access, NTLM, and Kerberos for authentication with HTTP servers. Except for Kerberos, all these mechanisms are also supported for authentication with HTTP proxies. The BD Runtime supports Kerberos version 5 authentication.

By default, HTTP cookies received through Good Dynamics secure communication are handled automatically.

SQLite

Provides access to the Secure Database by adding the cordova-plugin-bbd-storage plugin to your project.

Sockets

Provides access to the secure Socket communications API by adding the cordova-plugin-bbd-socket plugin to your project.

Cordova Sample Applications

We have provided several Sample Applications which show best practices when using the BlackBerry Dynamics Plugins. These samples are shipped with the SDK and is great resource for anyone looking to develop apps that deeply integrate with the SDK.

Configure the Sample Applications

  • Open your favorite Terminal program
  • Change the directory to the BBD-SDK-FOLDER/folder:

$ cd …/BBD-SDK-FOLDER

  • Add Configure plug-in to application:

$ cordova plugin add cordova-plugin-bbd-configure

  • Add Platform to application:

For iOS: $ cordova platfrom add ios

For Android: $ cordova platform add android

  • Build desired sample app:

$ cordova build

You can deploy and test the sample applications using the methods covered on the Deploy & Test tab.

You may want to learn more about the BlackBerry Dynamics Plugins and how they work with your project. If you’ve built projects with Cordova plugins in the past, using the BlackBerry Dynamics plugins will be familiar to you.

Some features will automatically be available to your project after adding the cordova-plugin-bbd-base plugin such as FileSystem, XMLHttpRequest.

Generally, it’s recommended to use the cordova-plugin-bbd-all plugin to enable access to all BlackBerry Dynamics APIs. If more granular control is required, you can also install only the bare minimum of required plugins for your app.

A few items of note:

File System

This plugin overrides the default Cordova FileSystem object and provides access to the secure file system automatically upon installation of the cordova-plugin-bbd-base plugin.

HTTP

This plugin overrides the default XMLHttpRequest object automatically upon installation of the cordova-plugin-bbd-base plugin. Calls made via XHR will automatically route through the BlackBerry Dynamics Proxy.

When making HTTPS requests through an HTTP proxy, SSL/TLS certificate verification must be disabled. Certificate verification while using an HTTP proxy is not supported. BlackBerry Dynamics HTTP data communication does not go via the proxy specified in the device's native settings, if any.

The BlackBerry Dynamics Runtime supports Basic Access, Digest Access, NTLM, and Kerberos for authentication with HTTP servers. Except for Kerberos, all these mechanisms are also supported for authentication with HTTP proxies. The BD Runtime supports Kerberos version 5 authentication.

By default, HTTP cookies received through Good Dynamics secure communication are handled automatically.

SQLite

Provides access to the Secure Database by adding the cordova-plugin-bbd-storage plugin to your project.

Sockets

Provides access to the secure Socket communications API by adding the cordova-plugin-bbd-socket plugin to your project.

Cordova Sample Applications

We have provided several Sample Applications which show best practices when using the BlackBerry Dynamics Plugins. These samples are shipped with the SDK and is great resource for anyone looking to develop apps that deeply integrate with the SDK.

Configure the Sample Applications

  • Open your favorite Terminal program
  • Change the directory to the BBD-SDK-FOLDER/folder:

$ cd …/BBD-SDK-FOLDER

  • Add Configure plug-in to application:

$ cordova plugin add cordova-plugin-bbd-configure

  • Add Platform to application:

For iOS: $ cordova platform add ios

For Android: $ cordova platform add android

  • Build desired sample app:

$ cordova build

You can deploy and test the sample applications using the methods covered on the Deploy & Test tab.

Congratulations on developing your first BlackBerry secured app! You can continue to explore the available APIs and developer resources. Learn about some of the common APIs below.

The code snippets used in this section are from two Android Studio projects available for download here: Getting Started and Getting Started BD.

The secure file system is part of the BlackBerry Dynamics Secure Storage feature. For apps, the BlackBerry Dynamics (BD) secure file system behaves like the default file system, with the following differences:

  • All data within the secure file system is stored on the device in an encrypted form.
  • Directory and file names are also encrypted.
  • There is no current working directory in the secure file system. Paths should always be specified as absolute paths, beginning with a / character.
  • The secure file system cannot be accessed until BlackBerry Dynamics authorization processing is complete. For more information, see authorize in the GDAndroid class reference.

Encryption and decryption is transparent to the app code:

  • File-writing interfaces accept raw data. The BD Runtime encrypts the data and stores it on the device.
  • When a file-reading interface is utilized, the BD Runtime decrypts what was stored and returns plain data.
  • Path access interfaces accept plain parameters for directory and file names. The BD Runtime encrypts the parameter values in order to create paths in the secure store.
  • Directory and file names provided as return values are plain. The BD Runtime decrypts paths in the secure store in order to generate the return values.

The encryption method used by the BD Runtime generally requires that the user has entered a security password, from which an encryption key is derived. For more information, refer to the BD File I/O package documentation.

From a coding perspective, the BlackBerry Dynamics file system APIs are very similar to the standard Android file system APIs. The changes required are minimal and only involve changing some of the class names used. Comparing the before FileFragment.java and after FileFragment.java files, you’ll observe the following changes:

 

Update Import Statements

Original

import java.io.FileOutputStream;
import java.io.InputStream;

BlackBerry Dynamics

import com.good.gd.file.FileInputStream;
import com.good.gd.file.FileOutputStream;
import com.good.gd.file.GDFileSystem;

 

Use GDFileSystem to Open the File for Writing

Original

outputStream = getContext().openFileOutput(FILENAME, Context.MODE_PRIVATE);

BlackBerry Dynamics

outputStream = GDFileSystem.openFileOutput(FILENAME, Context.MODE_PRIVATE);

 

Use GDFileSystem to Open the File for Reading

Original

InputStream inputStream = getContext().openFileInput(FILENAME);

BlackBerry Dynamics

FileInputStream inputStream = GDFileSystem.openFileInput(FILENAME);

After making these minor changes, the app is now able to securely read and write encrypted files.

The secure SQL database is part of the BlackBerry Dynamics Secure Storage feature. Data stored in the secure SQL database will be encrypted on the device by the BlackBerry Dynamics Runtime. The BlackBerry Dynamics secure SQL database is based on the SQLite library. Encryption is added by BlackBerry Dynamics transparently to the app. A secure SQL database cannot be accessed until BlackBerry Dynamics authorization processing is complete.

BlackBerry Dynamics apps access the secure database using replacements for the native android.database and android.database.sqlite packages. To access the replacement classes instead of the native classes, change android.database to com.good.gd.database wherever it occurs in the app code.

The replacement packages support the same APIs as the native packages, with the following exceptions:

  • The LOCALIZED and UNICODE collators provided by the native android.database.sqlite package are not supported.
  • There is an additional function, importDatabase. See below for more information.
  • Paths of database files are interpreted relative to the root of the BlackBerry Dynamics secure file system of the app. The root of the secure file system is within the app's data directory. There is no need to utilize functions such as the native getFilesDir to generate database file paths.

For more on using SQLite databases refer to the SQLite package documentation.

If you compare the modifications required for SQLite in the before and after samples, you’ll notice that the only changes required are for the import statements. The rest of the SQLite in the app can remain as is. Here are the changes that were made:

 

Modify Import Statements in ColorDbHelp.java

Original

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

BlackBerry Dynamics

import com.good.gd.database.sqlite.SQLiteDatabase;
import com.good.gd.database.sqlite.SQLiteOpenHelper;

 

Modify Import in SqlFragment.java

Original

import android.database.sqlite.SQLiteDatabase;

BlackBerry Dynamics

import com.good.gd.database.sqlite.SQLiteDatabase;

This class is an extension of the Apache HttpClient for utilizing BlackBerry Dynamics secure communication. See the BD Communication Package for an introduction to the BlackBerry Dynamics secure communication feature. This class is a subclass of the native com.good.gd.apache.http.impl.client. DefaultHttpClient class and has the same API, with the following exceptions:

  • Some SSL certificate validation checking can be disabled for development purposes. This should not be done for production deployments.
  • The connection manager associated with a BD HTTP Client instance should always be closed by calling its shutdown() method, before the client instance is released or goes out of scope. This ensures that SSL verification can be re-enabled.
  • This class is not thread-safe. Use of ThreadSafeClientConnManager is not supported. This class only supports SingleClientConnManager.
  • Data communication does not go via the proxy specified in the mobile device's native settings, if any.
  • Kerberos authentication is supported.

If your BlackBerry UEM or Good Control server has disallowed connections to any server, the address of the destination app server must be registered in the UEM or GC management console.

The HTTP networking section of these samples are based on the Android HTTP network connection sample included with Android Studio. If you have also based your networking classes on this example, the changes to HttpFragment.java are concentrated within a single method. Refer to the before HttpFragment.java and after HttpFragment.java for complete code samples.

 

Update Import Statements

Original

import java.net.HttpURLConnection;
import java.net.URL;

BlackBerry Dynamics

import com.good.gd.apache.http.HttpResponse;
import com.good.gd.apache.http.client.methods.HttpGet;
import com.good.gd.net.GDHttpClient;

 

Modify the downloadUrl Method

Original

private InputStream downloadUrl(String urlString) throws IOException {
    URL url = new URL(urlString);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setReadTimeout(10000 /* milliseconds */);
    conn.setConnectTimeout(15000 /* milliseconds */);
    conn.setRequestMethod("GET");
    conn.setDoInput(true);
    // Start the query conn.connect();
    InputStream stream = conn.getInputStream();
    return stream;
}

BlackBerry Dynamics

private InputStream downloadUrl(String urlString) throws IOException {
    GDHttpClient httpclient = new GDHttpClient();
    final HttpGet request = new HttpGet(urlString);

    HttpResponse response = httpclient.execute(request);
    InputStream stream = response.getEntity().getContent();

    return stream;
}

This class is an extension of the native java.net.Socket class, for utilizing BlackBerry Dynamics secure communication. See the BD Communication Package for an introduction to the BlackBerry Dynamics secure communication feature.

This class offers the same API as the java.net.Socket class, with the exception of the following features that are not supported:

  • Out of band data
  • Urgent messages feature
  • Traffic class
  • Server socket methods (such as accept( ))
  • bind() method
  • connect (SocketAddress) method

If the app attempts to use an unsupported feature, a java.lang.UnsupportedOperationException is thrown. Only the default constructor is supported. Other constructors, for example those with parameters for proxy or host address, are not supported.

A GDSocket must always be closed by calling the close() method to prevent resource contention. This applies even if the socket was never connected or used. An unused java.net.Socket object can be safely abandoned without the need for an explicit close.

Data communication does not go via the proxy specified in the mobile device's native settings, if any. The getInetAddress() method does not return the address of the connected remote host.

If your BlackBerry UEM or Good Control server has disallowed connections to any server, the address of the destination app server must be registered in the enterprise's UEM or GC management console.

For more information, see the GDSocket class reference.

Looking at the modifications required for socket connections in the samples, the required changes are almost limited to changing the import statement and class name. There is one other minor modification because the constructor for Socket and GDSocket differ slightly. Refer to the before Socketfragment.java and after Socketfragment.java files for complete code samples.

 

Update Import Statements

Original

import java.net.Socket;

BlackBerry Dynamics

import com.good.gd.net.GDSocket;

 

Update Class Name and Constructor to use connect Method

Original

Socket socket = null;
socket = new Socket("developer.blackberry.com", 80);

BlackBerry Dynamics

GDSocket socket = null;
socket = new GDSocket();
socket.connect("developer.blackberry.com", 80, 1000);

Congratulations on developing your first BlackBerry secured app! You can continue to explore the available APIs and developer resources. Learn about some of the common APIs below.

The code snippets referenced in this section are available in the iOS sample apps from the BlackBerry GitHub site. Download the BlackBerry Dynamics iOS Samples repository and see these projects:

  • Basic-iOS-Sample-Objective-C
  • Basic-iOS-Sample-Swift
  • BlackBerry Dynamics iOS-Objective-C Sample
  • BlackBerry Dynamics iOS–Swift Sample

To see the full details of BlackBerry Dynamics APIs, see the BlackBerry Dynamics SDK API Reference.

The secure file system is part of the BlackBerry Dynamics Secure Storage feature. For apps, the BlackBerry Dynamics secure file system behaves like the default file manager system, with the following differences:

  • All data within the secure file system is stored on the device in an encrypted form.
  • Directory and file names are also encrypted.
  • There is no current working directory in the secure file system. Paths should always be specified as absolute paths, beginning with a / character.
  • The secure file system cannot be accessed until BlackBerry Dynamics authorization processing is complete. For more information, see authorize in the GDiOS class reference.

Encryption and decryption is transparent to the app code:

  • File-writing interfaces accept plain data. The BD Runtime encrypts the data and stores it on the device.
  • When a file-reading interface is utilized, the BD Runtime decrypts what was stored and returns plain data.
  • Path access interfaces accept plain parameters for directory and file names. The BD Runtime encrypts the parameter values to create paths in the secure store.
  • Directory and file names provided as return values are plain. The BD Runtime decrypts paths in the secure store to generate the return values.

The encryption method used by the BD Runtime generally requires that the user has entered a security password from which an encryption key is derived.

Since the GDFileManager class is a subclass of the native NSFileManager class, minimal changes are required. You just need to replace references to NSFileManager with references to GDFileManager.

Comparing before and after code snippets from the two sample apps, you’ll observe the following changes:

Import Statements

Native

@import <Foundation/Foundation.h>;

BlackBerry Dynamics

#import <GD/GDFileManager.h>

 

Use GDFileSystem to Write a File

Native

- (BOOL)writeToNativeFile
{

NSString *text = @"Text not protected.";
NSData *fileData = [text dataUsingEncoding:NSUTF8StringEncoding];

BOOL fileCreated = [[NSFileManager defaultManager] createFileAtPath:[self
documentsFolderPathForFileNamed:@"NativeFileTest.txt"] contents:fileData attributes:nil];

return fileCreated;

}

Objective-C

- (BOOL)writeToGDFile
 {
     NSString *text = @"Text to be protected by BlackBerry Dynamics.";
     NSData *fileData = [text dataUsingEncoding:NSUTF8StringEncoding];
    // Following assignment uses GDFileManager instead of NSFileManager.
     BOOL fileCreated =
     [[GDFileManager defaultManager]
      createFileAtPath:[self
                        documentsFolderPathForFileNamed:@"MyFile.txt"]
                        contents:fileData
                        attributes:nil];
     return fileCreated;
 }

Swift

func writeToGDFile() -> Bool
    {
        let text = “Text to be protected by GD encryption.”
        let fileData = text?.data(using: .utf8)
        let filePath = “ ”;
    //Create a secure file using GDFileManager
        let fileCreated = GDFileManager.default().createFile(atPath: filePath,
        contents: fileData, attributes: nil)
    return fileCreated
    }

After making these minor changes, the app is now able to securely write encrypted files.

The secure SQL database is part of the BlackBerry Dynamics Secure Storage feature. Data stored in the secure SQL database is encrypted on the device by the BD Runtime. The BlackBerry Dynamics secure SQL database is based on the SQLite library. Encryption is added by BlackBerry Dynamics transparently to the app. A secure SQL database cannot be accessed until BlackBerry Dynamics authorization processing is complete.

BlackBerry Dynamics apps access the secure database using replacements for the native SQLite. To access the replacement classes instead of the native classes, change the import statement sqlite3.h to GD/sqlite3enc.h.

For more information about using SQLite databases, refer to the Secure SQL Database API.

If you compare the modifications required for SQLite between the native samples and the GD sample, you’ll notice that the changes are minimal. Updates are required to the import statements and opening and importing of an encrypted database. The rest of the SQLite in the app can remain as is. Here are the changes that were made:

 

Import Statements

Native

#import <sqlite3.h>

BlackBerry Dynamics

#import <GD/sqlite3enc.h>

 

Open Database

Native

BOOL result = sqlite3_open([dbFileName UTF8String], &sqlite3Database);

BlackBerry Dynamics

Objective-C

sqlite3 *db_ptr = NULL;
    char *errorMsg = NULL;
    int returnCode;
    char *databaseName = NULL;
databaseName = "sample.db";
returnCode = sqlite3enc_open(databaseName, &db_ptr);
if(returnCode!=SQLITE_OK)
    {
        fprintf(stderr, "Error in opening the database. Error: %s", sqlite3_errmsg(db_ptr));
        sqlite3_close(db_ptr);
        return;
    }

Swift

func openSQLiteConnection() ->Bool
    {
        var db: OpaquePointer? = nil
        let returnCode = sqlite3enc_open("", &db)
        if returnCode == SQLITE_OK
        {
            return true
        }else {
            return false
        }
    }

GDURLLoadingSystem

BlackBerry Dynamics applications can use the native URL Loading System. The native URL Loading System classes can be used to communicate with app servers that are residing behind an enterprise firewall or on the Internet. Once a connectivity profile is configured in BlackBerry UEM or in standalone Good Control for secure communication, the native class NSURLSession or NSURLConnection should work as is.

See the BlackBerry Dynamics SDK API Reference and review the GDURLLoadingSystem class and NSURLSession support.

GDHttpRequest API as an alternative approach

In addition to the GDURLLoadingSystem, you can use the GD HTTP Request API to send HTTP requests, such as GET and POST, from the device to an app server. The app server can be on the Internet or behind the enterprise firewall as well. The GD HTTP Request API is based on the XML Http Request (XHR) standard.

BlackBerry Dynamics secure communications support HTTPS, using a Secure Socket Layer connection or SSL/TLS to send the HTTP request and receive the response. HTTP and HTTPS requests can be relayed by an HTTP or HTTPS proxy that resides on the Internet or behind the enterprise firewall. Authentication with the proxy is supported.

When making HTTPS requests through an HTTP proxy, SSL/TLS certificate verification must be disabled. Certificate verification while using an HTTP proxy is not supported. BlackBerry Dynamics HTTP data communication does not go via the proxy specified in the device's native settings, if any.

The BlackBerry Dynamics Runtime supports Basic Access, Digest Access, NTLM, and Kerberos for authentication with HTTP servers. Except for Kerberos, all of these mechanisms are also supported for authentication with HTTP proxies. The BD Runtime supports Kerberos version 5 authentication.

By default, HTTP cookies received through BlackBerry Dynamics secure communication are handled automatically.

For more information, see the GDHTTPRequest class reference. The changes required for the GD HttpRequest class are listed below:

Objective-C

// Open a requested URL using URLSession
    - (void)requestData:(NSString*)url
    {
        NSURL* nsUrl = [NSURL URLWithString:url];
        NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration
        defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]];
    
    NSURLSessionTask *task =
        [session dataTaskWithURL:nsUrl completionHandler:^(NSData *data, NSURLResponse
        *response, NSError *error){           
        self.dataReceivedTextView.text = [[NSString alloc] initWithData:data
        encoding:NSUTF8StringEncoding];
        }];
    
    [task resume];
    }

Swift

// Open a requested URL using URLSession
    func requestData(url : String)
    {   
        let nsUrl = URL(string: url)
            let urlRequest = URLRequest(url: nsUrl!)
            let session = URLSession.init(configuration: URLSessionConfiguration.default, delegate:
            self, delegateQueue: OperationQueue.init())
        
        let task = session.dataTask(with: urlRequest, completionHandler: { (data, response, error) in
            
            DispatchQueue.main.async {
                    print(response ?? "res")
                }
            })
            task.resume()
        }

The GD Socket API is asynchronous and state-based. The app attaches its own event-handler callbacks to the GD Socket object. The callback functions are invoked when socket events occur, or when the socket changes state. The API functions that can be called by the app depend on the socket's state.

Sending data through a GD Socket is a two-stage operation. The first stage is to add the data to the socket's outbound buffer. The socket's outbound buffer is represented by the writestream property, and is accessed using the GD Direct Byte Buffer API. The second stage is to send the contents of the buffer through the socket connection. To send the buffer, call the write function.

Reading data from a GD Socket is asynchronous. When data is received at the device, the data is stored in the socket's inbound buffer. The app is then notified that data is available to read, by invocation of the delegate onRead callback. In the callback, the app consumes the received data from the inbound buffer. The inbound buffer is represented by the readStream property, and is accessed using the GD Direct Byte Buffer API.

The GD Socket API supports use of SSL/TLS to send and receive data. By default, the BD Runtime does not offer the TLSv1.1 or TLSv1.2 protocols for SSL/TLS connections with an app server.

These protocols can be enabled, as follows:

1. Add a new row to the app's Info.plist file as follows:

Key: GDControlTLSVersions

Type: String (the default)

2. Set the value to:

GDEnableTLS1.1 to enable the TLSv1.1 protocol

GDEnableTLS1.2 to enable the TLSv1.1 and TLSv1.2 protocols

Alternatively, the value can be an array containing one or both of the above strings as separate items.

The GD socket connections and HTTP requests can be used to connect to servers that are behind the enterprise firewall. The address of the destination app server must be registered in the BlackBerry UEM or standalone Good Control (GC) management console.

  • The address could be registered as the app's server or as an additional server.
  • The app server configuration in the GC can be obtained in the app code by using the getApplicationConfig (GDiOS) function.

The connection to the app server will be made through the BlackBerry Dynamics proxy infrastructure. Verify the status of the mobile app's connection to the proxy infrastructure before attempting to open the socket or sending the HTTP request.

The changes required for the GDSocket class are listed below:

 

Import Statements

Native

#include <CoreFoundation/CoreFoundation.h>

BlackBerry Dynamics

#import <GD/GDNETiOS.h>

 

Connect to Server and Update Read/Write Stream Methods

Native

// connect to server, setting up network socket stream - (IBAction)connectToServer:(id)sender {

NSURL *urlString = [NSURL URLWithString:urlStr];

CFReadStreamRef readStream; CFWriteStreamRef writeStream;

CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)[ urlString host], 80, &readStream,
&writeStream);

NSInputStream *inputStream = (__bridge_transfer NSInputStream *)readStream; NSOutputStream
*outputStream = (__bridge_transfer NSOutputStream *)writeStream;

[inputStream setDelegate:self]; [outputStream setDelegate:self];

[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

[inputStream open]; [outputStream open]; } }

Objective-C

//initialize, connect, read, write, disconnect self.GDSocket = [[GDSocket alloc] init:serverURL
onPort:port andUseSSL:NO]; [self.GDSocket connect]; -(void)onOpen:(id)socket_id { GDSocket
*socket = (GDSocket *)socket_id;

[socket.writeStream write:"MESSAGE\n"];

[socket write];

} -(void)onRead:(id)socket_id { GDSocket *socket = (GDSocket *)socket_id;

NSString *dataString = [socket.readStream unreadDataAsString]; // all data has been
received [socket disconnect]; } }

Swift

func connectToServer()
    {
            let intCast : Int32 = Int32(self.portText.text!)!
            let nsstring : NSString = NSString.init(string: self.ipAddressText.text!)
            gdSocket = GDSocket(nsstring.utf8String!, onPort: intCast, andUseSSL: false)        
        gdSocket.delegate = self
            gdSocket.connect()
    }
   
    func onOpen(_ socket: Any)
    {
            let httpString =
            "GET http://\(self.ipAddressText.text!)/
            HTTP/1.1\r\nHost:\(self.ipAddressText.text!):\(self.portText.text!)\r\nConnection:
            close\r\n\r\n" as NSString
                    
        gdSocket.writeStream?.write(httpString.utf8String!)      
        gdSocket.write()
        }
func onRead(_ socket: Any)
    {
            let gSocket = socket as! GDSocket;        
        let str = gSocket.readStream?.unreadDataAsString()
            DispatchQueue.main.async {
                self.dataRecievedTextVIew.text = str as String!
            }
            gSocket.disconnect()
    }

      

Get Started with Other Platforms

BlackBerry also supports Windows,  Xamarin and macOS. 

Use these manuals to get started: Windows    |    Xamarin.iOS    |    Xamarin.Android    |    macOS