BlackBerry recently released BlackBerry Enterprise Bridge, which aims to solve the problem where users would have to edit their Microsoft Office files outside of their company’s secure managed application environment on their mobile devices. BlackBerry Enterprise Bridge helps to create a secure connection between BlackBerry Dynamics applications – such as BlackBerry Work – and Microsoft mobile apps, including Microsoft PowerPoint, Word and Excel.
Out of the box this capability exists in BlackBerry Work, allowing you to securely edit a file you’ve received as an attachment. You can also securely email a file from a Microsoft mobile app using BlackBerry Work. But this isn’t limited to BlackBerry Work, this feature is available to any BlackBerry Dynamics app. The initial release of BlackBerry Enterprise Bridge allows third party BlackBerry Dynamics applications to securely send files to Microsoft mobile apps. The ability to go the other way – from a Microsoft mobile app to a third party BlackBerry Dynamics app – is scheduled for a future release.
How Can I Do This?
The method to integrate with BlackBerry Enterprise Bridge is one you may already be familiar with. It makes use of BlackBerry Dynamics Shared Services (also known as App Kinetics) to securely send a file from your application to BlackBerry Enterprise Bridge, which will then handle securely sending the file to the Microsoft Mobile app without having to save the file in an unsecure, intermediate location.
Sample Apps
We have released a full sample app for Android that demonstrates how this can be done and sample code for iOS inline in this article. The samples take a Microsoft Word document, store it in the BlackBerry Dynamics secure file system and then securely send that file to Microsoft Word using BlackBerry Enterprise Bridge. You can jump straight to the sample using the following link.
Cross The Bridge – Android Sample
How the Samples Work
The first step the samples perform is to check to see if BlackBerry Enterprise Bridge is available. To do that, it queries for all application service providers that provide the edit file service.
Android
Vector<GDServiceProvider> providers = GDAndroid.getInstance().getServiceProvidersFor( EDIT_FILE_SERVICE, "1.0.0.0", GDServiceType.GD_SERVICE_TYPE_APPLICATION); String serviceDetails = parseServiceDetails(providers);
iOS
let providers = GDiOS.sharedInstance().getServiceProviders(for: EDIT_FILE_SERVICE, andVersion: "1.0.0.0", andServiceType: .application) let bridgeAvailable = parseServiceDetails(providers: providers)
This method will return all local application service providers that support the edit file service. Next, we search those provides to determine if the BlackBerry Enterprise Bridge edit file service was present.
Android
//Searches the service providers for the BlackBerry Bridge edit file service. private String parseServiceDetails(Vector<GDServiceProvider> providers) { //Creates the string to display on screen. StringBuffer sb = new StringBuffer(); for (int count = 0; count < providers.size(); count++) { GDServiceProvider provider = providers.get(count); if (BLACKBERRY_BRIDGE_APP_ID.equalsIgnoreCase(provider.getIdentifier())) { sb.append("BlackBerry Bridge detected."); Vector<GDServiceDetail> serviceDetails = provider.getServices(); for (int serviceCount = 0; serviceCount < serviceDetails.size(); serviceCount++) { GDServiceDetail serviceDetail = serviceDetails.get(serviceCount); if (EDIT_FILE_SERVICE.equalsIgnoreCase(serviceDetail.getIdentifier())) { sb.append("
BlackBerry Bridge edit file service detected."); sb.append("
Ready to edit document."); //Enable the edit button. editButton.setEnabled(true); } } } } if (sb.length() == 0) { sb.append("
BlackBerry Bridge not found."); } return sb.toString();
iOS
func parseServiceDetails(providers : [GDServiceProvider]) -> Bool { var bridgeAvailable = false for provider in providers { if BLACKBERRY_BRIDGE_APP_ID.lowercased() == provider.identifier.lowercased() { let serviceDetails = provider.services for serviceDetail in serviceDetails { if EDIT_FILE_SERVICE.lowercased() == serviceDetail.identifier.lowercased() { bridgeAvailable = true break; } } } } return bridgeAvailable; }
After finding the required service, the sample can initiate the process to send the file through BlackBerry Enterprise Bridge to Microsoft Word. The file to be sent must be stored in the BlackBerry Dynamics secure file system. For simplicity, the code for copying a file to that location is omitted below. Have a look at the full sample project to view that code.
Android
final File file = getDocFile(); try { GDServiceClient.sendTo(BLACKBERRY_BRIDGE_APP_ID, EDIT_FILE_SERVICE, SERVICE_VERSION, SERVICE_METHOD, null, new String[]{file.getAbsolutePath()}, GDICCForegroundOptions.PreferPeerInForeground); } catch (final GDServiceException gdServiceException) { TextView output = view.findViewById(R.id.outputTextView); output.setText("Exception: " + gdServiceException.getMessage()); }
iOS
let file = Bundle.main.path(forResource: "test", ofType: ".docx") do { try GDServiceClient.send(to: BLACKBERRY_BRIDGE_APP_ID, withService: EDIT_FILE_SERVICE, withVersion: "1.0.0.0", withMethod: "editFile", withParams: nil, withAttachments: [file!], bringServiceToFront: .GDENoForegroundPreference, requestID: nil) } catch { print(error.localizedDescription) }
Wrapping Up
Using the code above you can now allow users of your applications to securely view and edit Microsoft Office documents, while the files remain in their company’s secure managed application environment. Visit our BlackBerry Developer Forums to ask any questions about this code or how to implement it in your applications.