The ability to share files between enterprise apps is a key component of mobile workflows. Each application manages its own secure file container, so to share a file, you’re sending the file from one secure container to the next. The process sends the file encrypted, so that your file, whether at rest or in transit, is always secure.
The Good Dynamics (GD) Transfer File Service enables the secure transfer of files between Good-secured apps. In this post, I will walk you through the GD APIs used for the Transfer File Service based on the GD sample app, AppKinetics and Good Work. The sample application is available in the GD Examples folder when you download the GD SDK for iOS as well as for Android.
Registering Transfer File Service
GD Transfer File Service follows a consumer-provider model. One app provides a registered service and the other app consumes. The following diagram demonstrates the first use cases below for the Transfer File service between the AppKinetics sample app and Good Work.
- A user receives an attachment file via Good Work (consumer) and tries opening the attached document with the App Kinetics (provider) app using the “Open In” menu.
- A user views/opens a file in the App Kinetics app and sends the file to Good Work using the “SendTo” menu. Then Good Work creates an email placing the transferred file as an attachment.
In order for other GD apps to consume (request) the Transfer File Service for a GD app, the app, which can process the requests, MUST be registered as a service provider via the GC console. The available services are listed under Good Control > Apps > Manage Services.
Good ISV partner apps can do the same via their GDN Partner Group page.
Implementing Transfer File Service
Transfer File Service is one of the inter-application communication (ICC) features. ICC enables secure exchange of data between two Good Dynamics applications running on the same device.
The sequence of APIs used in a typical Transfer File Service involves:
1. The consumer application calls the service discovery API.
The Good Work app would query Transfer File Service using the call (GDiOS):
getServiceProvidersFor - (NSArray*) getServiceProvidersFor:(NSString *) serviceId andVersion: (NSString *) version andType: (GDServiceProviderType) serviceProviderType
This function returns a list of the available providers of a specified service.
2. The consumer application calls sendTo (GDServiceClient).
Good Work calls SendTo to send a service request (GDiOS) to AppKinetics:
+ (BOOL) sendTo: (NSString *) application withService: (NSString *) service withVersion: (NSString *) version withMethod: (NSString *) method withParams: (id) params withAttachments: (NSArray *) attachments bringServiceToFront:(GDTForegroundOption) option requestID: (NSString **) requestID error: (NSError **) error
3. The GDServiceDidReceiveFrom callback in the provider application is invoked by the ICC system.
AppKinetics’ implementation: GDServiceDidReceiveFrom
- (void) GDServiceDidReceiveFrom: (NSString*)application forService: (NSString*)service withVersion: (NSString*)version forMethod: (NSString*)method withParams: (id)params withAttachments: (NSArray*)attachments forRequestID: (NSString*)requestID
This callback is invoked when a service request is sent to the application within the Good ICC system. When this callback is invoked, the provider application must check that the service request is valid and process the request, if valid.
4. The provider application executes any required processing and then calls replyTo (GDService).
AppKinetics’ implementation: ReplyTo. If required by the service definition or other published API, respond to the request with a success or failure result by calling the replyTo (GDService) function.
+ (BOOL) replyTo: (NSString *) application withParams: (id) params bringClientToFront: (GDTForegroundOption) option withAttachments: (NSArray *) attachments requestID: (NSString *) requestID error: (NSError **) error
The results object will notify the Good Work app(consumer) with the success or failure of the request.
5. The GDServiceClientDidReceiveFrom callback in the consumer is invoked by the ICC system.
Good Work’s implementation: GDServiceClientDidReceiveFrom
- (void) GDServiceClientDidReceiveFrom: (NSString *) application withParams: (id) params withAttachments: (NSArray *) attachments correspondingToRequestID: (NSString *) requestID
This callback is invoked when a response is received to a service request that was sent within the Good ICC system.
As a result of the execution, the attachment file from the Good Work app is securely transferred to the AppKinetics app and opened.
That’s it for now.