Client Resources

SAPcpmsClientResources


Overview of the Client Resources Service API: GET Client Resources Service

The component downloads client resources from SAP Mobile Services. The two option are for downloading resources are:

  • download into memory as Data
  • download into a File as giving the file path

The component could list all the resources of an application.

Background download is not supported.

Usage

Setting up SAPcpmsClientResources

Use the SAPFoundation framework’s SAPcpmsClientResources component implementation. Create an SAPURLSession and add it to one of the initializers.

a.) Convenience initializer

This sample code demonstrates how to create an SAPcpmsClientResources instance with the convenience init:

var urlSession = SAPURLSession()
let settingsParameters = SAPcpmsSettingsParameters(backendURL: <#URL only with domain#>, applicationID: <#appid#>)
let clientResources = SAPcpmsClientResources(sapURLSession: urlSession, settingsParameters: settingsParameters)

b.) Default initializer

The designated initializer requires the Client Resources URL in the following format: https:///mobileservices/application/{applicationId}/bundles/v1/runtime/bundle/application/{applicationId}

var urlSession = SAPURLSession()
let clientResources = SAPcpmsClientResources(sapURLSession: urlSession, clientResourcesURL: <#Client Resources URL#>)

Downloading client resources from cloud

Default

Download the default client resources from mobile services:

clientResources.downloadResource { data, error in
    // use data and handle error here
}

Latest

Download the latest client resources from mobile services:

clientResources.downloadResource(named: <#client resource name#>) { data, error in
    // use data and handle error here
}

Specific version

Download client resources with a specific version from mobile services:

clientResources.downloadResource(named: <#client resource name#>, version: <#client resource version#>) { data, error in
    // use data and handle error here
}

Download to file

Download the client resources from mobile services into file:

clientResources.downloadResource(named: <#client resource name#>, toFile: <#path component#>) { error in
    // handle error here
}

Download list of the available client resources from cloud

Download list of ResourceInfo:

clientResources.fetchResourceInfo { resourceInfo, error in
    // use resourceInfo and handle error here
}

The ResourceInfo contains the name, version and the extension of the resource.

  • Information about a single resource

    See more

    Declaration

    Swift

    public struct ResourceInfo
  • The SAPcpmsClientResources Downloads client resources or information about resources from mobile services. It uses the SAP Mobile Services Client Resources Service API endpoint for that.

    This sample code demonstrates how to create an SAPcpmsClientResources instance:

    var urlSession = SAPURLSession()
    let settingsParameters = SAPcpmsSettingsParameters(backendURL: <#URL only with domain#>, applicationID: <#appid#>)
    let clientResources = SAPcpmsClientResources(sapURLSession: urlSession, settingsParameters: settingsParameters)
    
    See more

    Declaration

    Swift

    open class SAPcpmsClientResources
  • Error types that can throw this framework

    See more

    Declaration

    Swift

    public enum SAPcpmsClientResourcesError : Error
    extension SAPcpmsClientResourcesError: SAPError