Classes

The following classes are available globally.

  • AuthorizationHandler to perform authorization against the PredixMobile authorization service.

    Given a valid authenticated user, this class interacts with the Predix Mobile session service to initialize a session, and return user information.

    See more

    Declaration

    Swift

    open class PredixMobileAuthorizationHandler: AuthorizationHandler
  • AuthenticationManager manages the overall authentication, authorization, and deauthentication process.

    It does this by determining what type of authentication is needed based on the current system state and the provided configuration, and then passes detailed authentication tasks to AuthenticationHandler modules. Each implementer of the AuthenticationHandler protocol should implement one type of authentication.

    In this way, based on configuration, AuthenticationManager will automatically handle online and offline authentication and if so configured will utilize Touch ID for subsequent authentications after an initial online login was performed successfully.

    Example:*

    // First, create and populate our configuration
    var config = AuthenticationManagerConfiguration()
    let url = URL(string: "https://auth.myserver.com")
    config.baseURL = url
    config.clientId = "my_oauth_client_id"
    config.clientSecret = "my_oauth_client_secret"
    config.useTouchID = true // TouchId for refresh and offline authentication is disabled by default.
    
    // Next, create an AuthenticationManager object with the configuration
    let manager = AuthenticationManager(configuration: config)
    
    // Assign an OnlineAuthenticationHandler or subclass. In this case, UAABrowserAuthenticationHandler provides support for browser-based UAA login
    let onlineHandler = UAABrowserAuthenticationHandler(redirectURI: "predixmobile://foobar")
    
    // Assign a refresh handler to allow for refreshing a token without having to do a full login again
    onlineHandler.refreshAuthenticationHandler = UAARefreshAuthenticationHandler()
    
    // Set delegates as needed
    onlineHandler.authenticationBrowserDelegate = self
    
    // Assign the OnlineAuthenticationHandler to the manager
    manager.onlineAuthenticationHandler = onlineHandler
    
    // Similarly, assign an OfflineAuthenticationHandler for offline authentication support
    manager.offlineAuthenticationHandler = OfflineAuthenticationHandler()
    
    // And assign an AuthorizationHandler class for calling the authorization service after authenticating.
    manager.authorizationHandler = PredixMobileAuthorizationHandler()
    
    // Then call authenticate. The completionHandler will be called when the authentication process finishes.
    manager.authenticate { (status) in
        print("Authentication Status: \(status)")
    }
    
    See more

    Declaration

    Swift

    public class AuthenticationManager
  • Wrapper object used for returning the wait state of the UI. Encapsulates both the WaitState enumeration, and the optional string message.

    See more

    Declaration

    Swift

    @objc open class WaitStateReturn: NSObject
  • Allows an application to add monitor data that can be stored and transmitted once a user is online.    The MobileMonitor is a non-intrusive and non-blocking log collector that can be configured to be more or less aggressive with monitoring logs.  all items are processed in a serial queue on a background thread.  By default, the monitor will trace database events and report their status with a timestamp for debugging time critical operations.  It will also attempt to detect document conflicts  which can be a cause for concern for applications.    Additionally, applications can add their own monitoring and bundle it with the monitor items that are included by default.  This allows applications to dynamically collect logs when needed to help remotely route cause issues  without needed to send a new application to the device.    The monitor has been optimized to be non-intrusive to the running application, however users may still experience some lag if the monitor is set to aggressively collect, save and transmit logs.

    See more

    Declaration

    Swift

    public class MobileMonitor
  • Static class of elements Predix Mobile SDK consumers can use to adjust to configure aspects of the SDK.

    See more

    Declaration

    Swift

    @objc public class PredixMobilityConfiguration: NSObject
  • Base class for all AuthenticationHandlers.

    Provides common functions that all AuthenticationHandlers share.

    See more

    Declaration

    Swift

    open class AuthenticationHandler
  • Base class for all refresh authentication handlers used by an OnlineAuthenticationHandler

    Processes Oauth2 refresh-based authentication, where a refresh token is exchanged for an active authentication token with an authentication provider.

    Intended to allow for secure biometric or device passcode based authentication scenarios.

    In the expected process, the OnlineAuthenticationHandler.authenticationResponsePayload property will contain a refresh token. This token is then used by this handler during the next authentication request to refresh the authentication without needing the users credentials.

    See more

    Declaration

    Swift

    open class RefreshAuthenticationHandler: AuthenticationHandler, CallAuthenticationServiceProtocol
  • Used to create full text search database views.

    • example:

      PredixMobilityConfiguration.appendDataViewDefinition("views/searchtext", version: "1") { (properties: [String : Any], emit: (Any, Any?) -> Void) -> Void in
      
          if let body = properties["body"] as? String
          {
              emit(FullTextSearch.createKey(body), nil)
          }
      }
      
    See more

    Declaration

    Swift

    @objc open class FullTextSearch: NSObject
  • Stores user data, populated during the authentication process.

    See more

    Declaration

    Swift

    public class UserManager
  • Predix Mobile SDK main manager class

    Controls the interface between the container application and the SDK.

    See more

    Declaration

    Swift

    @objc public class PredixMobilityManager: NSObject
  • Database interaction class. Controls setup of replication, access to documents, manipulation of attachments, etc.

    See more

    Declaration

    Swift

    public class DatabaseManager: DatabaseManagerProtocol
  • The ServiceRouter controls what services are available or unavailable and processes service requests.

    When a service is registered it is made available to process requests. When it is unregistered it is no longer available to service requests.

    • All services registered must have a unique serviceIdentifier string.

    • Attempts to register a service with a serviceIdentifier string that is already registered will not be successful.

    See more

    Declaration

    Swift

    @objc public class ServiceRouter: NSObject, ServiceRouterProtocol
  • Provides the ability to open a URL on device external to app.

    URLs may launch different apps on the device, for example:

    • The URL mailto://someone@example.com?Subject=Hello%20again would open the mail app.

    • The URL tel:1-800-555-1212 would open the phone app, and initiate a phone call.

    • The URL https://www.google.com would open the Safari app.

    See more

    Declaration

    Swift

    public class OpenURLService: NSObject, ServiceProtocol
  • Allows an application developer to provide mock data responses for URLSession and other types of network request classes (UIWebView for example).

    The MockNetworkDataManager works with mock data providers to determine if a requested URL should return real network data or mock network data.

    By default the MockNetworkDataManager uses a default data provider that works with a resource bundle and plist to determine if a requested URL should return mock data. Here is an example of how the default provider works:

    In a project define a MockData.bundle resource bundle, inside that bundle it should contain all of the contents you need to mock a network response for a request. The bundle should also include a DataMapping.plist file.

    Example: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd> https://apple.com dataFilename mockData.json requests httpMethod GET headerFields a b response headerFields a b httpVersion 1.1 statusCode 200 httpMethod POST

    Alternatively you can define a simple response structure, this will return the response for ANY requests sent for the given endpoint

    <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd> https://simple.com dataFilename mockData.json response headerFields a b httpVersion 1.1 statusCode 200

    The data is loaded from disk as raw Data using the contents of file as the data response. This means the default provider should be able to work with most file types (JSON, text, images, video, etc.)

    See more

    Declaration

    Swift

    open class MockNetworkDataManager: NSObject
  • Handles methods for application lifecycle events, local and remote notifications.

    If PredixMobilityConfiguration.automaticallyListenForApplicationStateEvents is true, the SDK will automatically handle application lifecycle events, however local and remote notification event method calls will need to be passed to the SDK from the container app.

    See more

    Declaration

    Swift

    public class ApplicationDelegateHandlers