Destinations

SAPcpmsDestinations


Loads the configured destination name(s) and path(s) from SAP Mobile Services.

Usage

Setting up SAPcpmsDestinations

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

a.) Convenience initializer

The recommended initializer is using the SAPcpmsSettingsParameters as a parameter:

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

Only the ‘backendURL’ and the ‘applicationID’ parameters are used from SAPcpmsSettingsParameters to create the full URL.

b.) Default initializer

The default initializer uses SAPURLSession and the full URL of the mobile services endpoint service as an input

var urlSession = SAPURLSession()
let destinations = SAPcpmsDestinations(sapURLSession: urlSession, destinationsServiceUrl: <#destinationServiceURL#>)

Loading destination information from cloud

Load the destination information from mobile services:

destinations.load { destinationInfo, error in
    // use destinationInfo dictionary and handle error here
    let settingsParameters = SAPcpmsSettingsParameters(backendURL: <#url#>, applicationID: <#appID#>, destinations: destinationInfo)
}

Or you can use the convenience method which will return you an updated ‘SAPcpmsSettingsParameters’ instance:

destinations.load(to: <#settingsParameters#>) { updatedSettingsParameters, error in
    // use updatedSettingsParameters and handle error here
}

Get the destination URL from ‘SAPcpmsSettingsParameters’:

    let destinationUrl = settingsParameters.url(forDestination: <#destinationName#>)

  • Loads the configured destination name(s) and path(s) from SAP Mobile Services.

    This sample code demonstrates how to create an SAPcpmsDestinations instance:

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

    Declaration

    Swift

    open class SAPcpmsDestinations
  • Enum covering all errors occuring in the SAPcpmsDestinations.

    See more

    Declaration

    Swift

    public enum SAPcpmsDestinationsError : Error
    extension SAPcpmsDestinationsError: SAPError