40
Predix SDK for Hybrid © 2020 General Electric Company

Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Predix SDK for Hybrid

© 2020 General Electric Company

Page 2: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Contents

Predix SDK for Hybrid 1

About Predix SDK for Hybrid 1

Predix Mobile Command Line Interface 3

Predix Mobile Command-Line Interface (pm CLI) Commands 3

Installing the pm Command-Line Interface 3

pm api 3

pm apps 4

pm auth 5

pm channels 6

pm conflicts 7

pm data-delete 7

pm define 7

pm grant 8

pm import 8

pm invalidate-session 8

pm logs 8

pm oauth-token 9

pm publish 9

pm revoke 10

pm routes 10

pm version 11

pm webapps 13

pm workspace 13

Predix Mobile Client Core Services Framework 14

Predix Mobile Client Core Services Framework 14

Predix Mobile Authentication Service 14

Predix Mobile Boot Service 14

Predix Mobile Command Service 15

Predix Mobile Connectivity Service 15

Predix Mobile Data Access Services 15

Predix Mobile Logging Service 16

Predix Mobile OpenURL Service 17

ii Predix SDK for Hybrid

Page 3: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Predix Mobile Notify Service 17

Predix Mobile User Information Service 18

Predix Mobile User Settings Service 19

Predix Mobile Version Service 19

Predix Mobile Window Service 21

Predix Mobile Client Advanced Services 21

Configuration Preferences and Properties 23

Configuration Preferences and Properties 23

Troubleshooting Predix Sync and SDK for Hybrid 25

Troubleshooting UAA Service 25

UAA User Account not Found 28

User Token Invalid - Expired 28

Authentication Not Valid when Creating User 29

Running pm CLI in Debug Mode 29

Developing Apps for Apple Devices 31

Developing Apps for Apple Devices 31

Build an App with Native iOS Components 31

Submitting a Predix Mobile Container to the Apple App Store 31

Release Notes 33

Release Notes 33

iii

Page 4: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Copyright GE Digital© 2020 General Electric Company.

GE, the GE Monogram, and Predix are either registered trademarks or trademarks of General Electric Company. All other trademarks are the property of their respective owners.

This document may contain Confidential/Proprietary information of General Electric Company and/or its suppliers or vendors. Distribution or reproduction is prohibited without permission.

THIS DOCUMENT AND ITS CONTENTS ARE PROVIDED "AS IS," WITH NO REPRESENTATION OR WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF DESIGN, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. ALL OTHER LIABILITY ARISING FROM RELIANCE UPON ANY INFORMATION CONTAINED HEREIN IS EXPRESSLY DISCLAIMED.

Access to and use of the software described in this document is conditioned on acceptance of the End User License Agreement and compliance with its terms.

iv © 2020 General Electric Company

Page 5: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Predix SDK for Hybrid

About Predix SDK for HybridThe Predix SDK for Hybrid includes Reference App Containers for various platforms, the pm command-linetool, and several services that help you to extend the container.

A Mobile Reference App Container is a native application that includes the Predix Mobile Client CoreServices framework that enables you to load, display, and run your Predix Mobile applications.

• For Android, you build the Predix Mobile Reference App Container for Android.• For iOS, you build the Predix Mobile Reference App Container for iOS.• For MacOS, you build the App Container for MacOS.

The Predix Mobile (pm) command-line tool allows you to manage your Predix Mobile apps and your mobileback-end processes. The pm CLI commands depend on the Cloud Foundry and UAAC command-line tools,so make sure they are installed and properly configured prior to installing the pm tool. See Predix MobileCommand-Line Interface (pm CLI) Commands on page 3.

The SDK for Hybrid provides several services as REST APIs to provide functionality to hybrid or nativeMobile applications. The Client SDK consuming application (Predix Mobile App Container) can interactwith these local services following this general URL structure: http://pmapi//<parameters>.

The Predix Mobile Reference App Container interprets URL requests and delegates them to the services inthe Predix Mobile Client Core Services framework , which respond with a JSON payload describing theresult of the call. See Predix Mobile Client Core Services Framework on page 14.

© 2020 General Electric Company 1

Page 6: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Figure 1: Predix Mobile Reference App Container and Mobile Service

See also https://github.com/PredixDev/PredixMobileSDK.

2 © 2020 General Electric Company

Page 7: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Predix Mobile Command Line Interface

Predix Mobile Command-Line Interface (pm CLI) CommandsPredix Mobile command-line interface (pm CLI) is a set of command line utility tools Use the pm CLI tomanage your Predix Mobile apps and Mobile Service processes.

The pm CLI includes a set of commands that are invoked through the pm command-line interface. The pmCLI commands use the following syntax:

pm [options] [command]

Installing the pm Command-Line InterfaceUse the pm CLI to manage Predix mobile users, roles, Predix mobile applications, and their web appdependencies.

Before You Begin

The pm CLI depends on both the Cloud Foundry (CF) and UAAC command-line tools.

• Install Cloud Foundry's cf CLI.See https://github.com/cloudfoundry/cli#downloads.

• Install Cloud Foundry's cf-uaac CLI.See https://github.com/cloudfoundry/cf-uaac and Troubleshooting UAA Service on page 25.

About This Task

Install the pm CLI:

Procedure

• Download the pm .zip file from https://github.com/PredixDev/predix-mobile-cli/releases/latest.

◦ For iOS and MacOS platforms, unpack the pm-v1.x.x-Mac.zip file in your workspace.◦ On the Windows platform, unpack the pm-v1.x.x-win.zip file in your workspace.

pm apiUse this command to display the current target, set the target, or change the target Predix Mobile ClientAPI Gateway service.

In a typical application-development workflow, you begin by targeting the Predix Mobile Client APIGateway service. The Client API Gateway and the UAA Service work together to ensure that all clientsthat access the Predix Mobile service possess a valid authentication token.

In this example, the command returns an empty target.

$ pm apiinfo: API>

© 2020 General Electric Company 3

Page 8: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

You can pass the URL of your Predix Mobile API Gateway host to the command to set or change the target.For example:

$ pm api https://015272.grc-apps.svc.ice.ge.cominfo: API> https://015272.grc-apps.svc.ice.ge.com

Run each pm command against the targeted Client API Gateway. If you do not set a target, any pmcommand fails with an error.

pm appsUse this command to list each Predix Mobile app defined in your Predix Mobile service.

$ pm apps┌──────────┬──────────────────────────────┬──────────┬────────────────────────────────────────┐│ Type │ Name │ Version │Channel │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ PM-APP │ FunctionalTestSuite │ 1.0.0 │ app-FunctionalTestSuite_1_0_0 ││ │ ││ │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ PM-APP │ ionic1 │ 1.0 │ app-ionic1_1_0 ││ │ ││ │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ PM-APP │ Sample1 │ 1.0 │ app-Sample1_1_0 ││ │ │ │ roler-user ││ │ │ │ role-user ││ │ ││ │└──────────┴──────────────────────────────┴──────────┴────────────────────────────────────────┘

Include the -w parameter to list web apps deployed with your defined Predix Mobile apps. For example:

$ pm apps -w┌──────────┬──────────────────────────────┬──────────┬────────────────────────────────────────┐│ Type │ Name │ Version │Channel │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ PM-APP │ FunctionalTestSuite │ 1.0.0 │ app-FunctionalTestSuite_1_0_0 ││ │ ││ │├──────────┼──────────────────────────────┼──────────┼─────────────────

4 © 2020 General Electric Company

Page 9: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

───────────────────────┤│ WEB-APP │ e2e-app-test │ 0.0.1 │ webapp-e2e-app-test_0_0_1 │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ │ ││ │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ PM-APP │ ionic1 │ 1.0 │ app-ionic1_1_0 ││ │ ││ │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ WEB-APP │ ionic_sidemenu │ 0.0.1 │ webapp-ionic_sidemenu_0_0_1 │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ │ ││ │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ PM-APP │ Sample1 │ 1.0 │ app-Sample1_1_0 ││ │ │ │ roler-user ││ │ │ │ role-user ││ │ ││ │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ WEB-APP │ sample-webapp │ 0.0.1 │ webapp-sample-webapp_0_0_1 │├──────────┼──────────────────────────────┼──────────┼────────────────────────────────────────┤│ │ ││ │└──────────┴──────────────────────────────┴──────────┴────────────────────────────────────────┘

pm authUse this command to authenticate a user against the currently targeted Predix Mobile API Gateway host.

Use the user name and password for an account that has been set up with UAA with the followingcommand:

$ pm auth [email protected]:info: API endpoint: https://d7dfcca0-c774-4f24-80b3-6c0c20106c8b.predix-uaa-staging.grc-apps.svc.ice.ge.cominfo: Authenticating...OK

© 2020 General Electric Company 5

Page 10: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

pm channelsUse this command to manage the readable channels assigned to each user.

For more information about channels, see . the Couchbase documentation.

Options

Option Description

-c, --channel [channel_name...] Specify one or more channels.

-D, --debug Set logging level to debug (returns more traces than

verbose)

-f, --format Format output in a tabular form.

-l, --list List channels.

-p, --purge Purge documents from all channels. The app.jsondefinition file is ignored.

-r, --role Assign a role to a user and assign multiple channels.

--skip-ssl-validation Ignore transport layer security (TLS) certificate validation errors.

u, --user [username...] Specify one or more users.

-v, --verbose Set logging level to verbose.

-h, --help List pm cli tool options.

Examples

Display user channel document:

$ pm channels -u [email protected] -l

Assign a channel to a user:

$ pm channels -u [email protected] -c test_channel

Delete (purge) a channel from user document:

$ pm channels -u [email protected] -c test_channel -p

Assign a role to a user:

$ pm channels -u [email protected] -r role-test

6 © 2020 General Electric Company

Page 11: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Work with multiple users or channels:

$ pm channels -u [email protected] -u [email protected] -c test_channel1 -ctest_channel2

$ pm channels -u [email protected],[email protected] -ctest_channel1,test_channel2

Note: Do not insert a space before or after a comma when you enter multiple users or channels with the-u and -c options.

pm conflictsUse this command to search for conflicted documents.

Conflicts arise when multiple users edit a single document. You can use the conflicts command tosearch and replace the conflicted document with latest document on the server.

The following example shows conflicted revisions :

$ pm conflicts

No id rev count conflictedrevisions1 workorders 2{"rev":"387-ab2e035219fb9f1da416b190e84ebd89"}

{"rev":"354-ab1d3b590bc6258c5cd0e54c2007a720"}

Total conflicted revisions 2OK

pm data-deleteUse this command to remove data from your Predix Mobile service.

The pm data-delete command takes the same parameters as the pm import command, the --data parameter that specifies the location of a raw JSON data file. It also takes an --app parameterthat specifies the path to the app.json file defining the target app for the data deletion. This commanddoes the inverse of the import command, disassociating each document from the main web app definedin the given app.json.

pm defineUse this command to define a Predix Mobile application as a collection of one or more web apps.

The pm define command accepts an --app parameter that specifies the path to an app.json file.This app.json file defines the application as a collection of one or more web apps.

© 2020 General Electric Company 7

Page 12: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

pm grantUse this command to grant access to a Predix Mobile app for a specified user account.

The pm grant command requires a single parameter specifying a Predix Mobile app by name or a pathto an app.json file. By default it operates on the current authenticated user. However, it also takes a --user parameter specifying a different user for an access grant.

pm importUse this command to import data into your Predix Mobile service.

The pm import command takes a --data parameter specifying the location of a raw JSON data file. Italso takes an -–app parameter specifying the path to an app.json file that defines the data import'starget app. The tool imports the data and associates it with the main web app defined in the specifiedapp.json file.

pm invalidate-sessionUse this command to invalidate active sessions for a user.

Admin can use this command to invalidate a user's active sessions and block the user from replicatingdata.

Option Description

-D, --debug Set logging level to debug (returns more traces than

verbose)

-h, --help List pm CLI tool options.

-v, --verbose Set logging level to verbose.

u, --user [username...] Specify one or more users.

Example

Invalidate session(s) for a user: $ pm invalidate-session -u [email protected]

pm logsUse this command to display access or error logs.

Use the pm logs command to show logs for a specified <service-name> and <log-type>, where:

• <service-name> is client-gatewayRepresents the primary public access point of a Predix Mobile service instance. All public traffic to andfrom a Predix Mobile service instance passes through this API Gateway.

• <log-type> is access or error◦ error

8 © 2020 General Electric Company

Page 13: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Represents the error log of the service. The log contains exceptional events, includingunrecoverable server exceptions.

To retrieve error logs of the client-gateway service:

$ pm logs client-gateway error◦ access

Represents the access log of the service. The log contains normal server HTTP/HTTPS accessevents.

To retrieve access logs of the client-gateway service:

$ pm logs client-gateway access

pm oauth-tokenUse this command to display the OAuth token for the currently authenticated user account.

The pm oath-token command dumps the raw token data to your standard output device. This can beused for debugging purposes when making authenticated requests from another tool such as cURL orPOSTman. In this case, run the command without parameters, copy the entire token, and add it as thevalue of the Authentication header field in a raw HTTP request.

$ pm oauth-tokeninfo: Getting OAuth token...info: OK

bearereyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJlOTZkZTUzMC0wYjU1LTRkZDEtOGRkZi1iODc1ZjgyOTAzZDkiLCJzdWIiOiJmZmRhYzcyYS1jYWQwLTRlZGUtOThlNi0xOTRmMDQyZDA1Y2IiLCJzY29wZSI6WyJwbS5hZG1pbiIsIm9wZW5pZCJdLCJjbGllbnRfaWQiOiJwbSIsImNpZCI6InBtIiwiYXpwIjoicG0iLCJncmFudF90eXBlIjoicGFzc3dvcmQiLCJ1c2VyX2lkIjoiZmZkYWM3MmEtY2FkMC00ZWRlLTk4ZTYtMTk0ZjA0MmQwNWNiIiwib3JpZ2luIjoidWFhIiwidXNlcl9uYW1lIjoiY2xpZnRvbi5jcmFpZ0BnZS5jb20iLCJlbWFpbCI6ImNsaWZ0b24uY3JhaWdAZ2UuY29tIiwiYXV0aF90aW1lIjoxNDU2NDIwMzg4LCJyZXZfc2lnIjoiNGNhOGRkNjUiLCJpYXQiOjE0NTY0MjAzODgsImV4cCI6MTQ1NjQ2MzU4OCwiaXNzIjoiaHR0cHM6Ly8xYTgxY2QxMy02MGI2LTQ1ZjgtYjJiYi1lZjQ5MTdkMzg4OTMucHJlZGl4LXVhYS5ydW4uYXdzLXVzdzAyLXByLmljZS5wcmVkaXguaW8vb2F1dGgvdG9rZW4iLCJ6aWQiOiIxYTgxY2QxMy02MGI2LTQ1ZjgtYjJiYi1lZjQ5MTdkMzg4OTMiLCJhdWQiOlsicG0iLCJvcGVuaWQiXX0.vEEXUx85u7NZ8owTduYOGteNOmDBnS5P_d5uhoSWgdypty0pVfcl4CWzoTkJ8AhDBP4jDZc3hhH6_yfJ-8uFdRklwOKlx5-DPWlCzs2DquJpiNCt1JiOpnQbM7aT1CvTXUUnmpZhRy80_fLSyHalrvfFSJp2UxJxkmNBUCKTA-M1bmQyuY4g0DJedW1GGi4CpGQrWk4teeulHK2AM4TQoWzq3Hlzq8sEm11p2nI9lqy_rGKU1rgyqxS5gs4leNrho1T65QHXBDLyI3gC3l8oaNJSIyTL389yE3EzQYabZcHsy7QPgrfTKyK_LEE-_z_4F_4YCeJpWt4QIpddMQI3Qw

pm publishUse this command to upload a Predix Mobile web app to your Predix Mobile service instance.

The pm publish command takes a –webapp parameter that specifies the path to a webapp.jsonfile. This file defines the web application to be published. The publish command grants accesspermission to the current authenticated user so you can load the app initially with the user account usedfor publishing. See the pm grant command for information on granting access to additional users.

© 2020 General Electric Company 9

Page 14: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

pm revokeUse this command to revoke access to a Predix Mobile app for a specified user account.

The pm revoke command requires a single parameter specifying a Predix Mobile app by name or a pathto an app.json file. By default it operates on the current authenticated user. However, it also takes a --user parameter where you can specify a different user for access revocation.

pm routesUse this command to list all defined routes that the Predix Command Router is aware of.

These routes are used to route commands to individual command processors, which are microservicesthat you deploy using Cloud Foundry cf tools. Any document created from your Predix Mobile web appwith a type equal to command can be routed to a command processor and processed.

A command router is a microservice that is tasked with routing pending command documents toconfigured command processors. A command document is a JSON document with a type field value ascommand and a status field. The command document format is similar to an HTTP request, with a requestand response section contained in the same document.

The Command Router manages the state of a given command from the time the document arrives on theserver until the router writes the result from an invoked Command Processor to the response section ofthe document. The Command Router translates a command document into an equivalent HTTP requestto a Command Processor. The HTTP response from the Command Processor is serialized and placed in theresponse section of the originating command document.

Related Reference

pm add-route on page 10

Use this command to associate an HTTP URL with a named Predix Mobile command route.

pm remove-route on page 11

Use this command to remove an HTTP URL associated with a named Predix Mobile command route.

pm add-routeUse this command to associate an HTTP URL with a named Predix Mobile command route.

For instance, a route named /search can be associated with the URL http://predix-mysearch-webapp.run.aws-usw02-pr.ice.predix.io. Any command discovered by the command router containing thisname is then be sent to the web service running at http://predix-mysearch-webapp.run.aws-usw02-pr.ice.predix.io to be processed.

Related Reference

pm routes on page 10

Use this command to list all defined routes that the Predix Command Router is aware of.

pm remove-route on page 11

10 © 2020 General Electric Company

Page 15: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Use this command to remove an HTTP URL associated with a named Predix Mobile command route.

pm remove-routeUse this command to remove an HTTP URL associated with a named Predix Mobile command route.

To remove a route named /legacy-addition-service, issue the following command:

$ pm remove-route /legacy-addition-service

Related Reference

pm routes on page 10

Use this command to list all defined routes that the Predix Command Router is aware of.

pm add-route on page 10

Use this command to associate an HTTP URL with a named Predix Mobile command route.

pm versionUse this command to retrieve version and device information.

Method: GETURL: http://pmapi/versionOutput: Status code 200, data in JSON dictionary form with the following keys:

Key Description SDK supported

predix_mobile_sdk_version

Version number of the Predix Mobile SDK iOS, MacOS, Android, JavaSDK

predix_mobile_sdk_build_version

Build version number of the Predix Mobile

SDK

iOS, MacOS, Android, JavaSDK

application_version Version number of the current container

app

iOS, MacOS

application_build_version

Build version number of the current

container app

iOS, MacOS

application_bundle_id Bundle ID of the iOS container app iOS, MacOS

server_hostname Configured server hostname iOS, MacOS, Android, JavaSDK

device_model Hardware description or device type iOS, MacOS, Android

device_OS Operating system name iOS, MacOS, Android, JavaSDK

device_OS_version Operating system version number iOS, MacOS, Android, JavaSDK

database_version Database version number iOS, MacOS, Android, JavaSDK

locale Current running locale iOS, MacOS, Android, JavaSDK

© 2020 General Electric Company 11

Page 16: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Key Description SDK supported

PredixMobileVersion Matches

predix_mobile_sdk_build_version

This key provided for compatibility. May

be deprecated in the future.

ContainerVersion Matches

application_build_version

This key provided for compatibility. May

be deprecated in the future.

SyncGateway Matches server_hostname This key provided for compatibility. May

be deprecated in the future.

Platform Differences

Due to differences in platforms, not all keys are supported on all platforms.

The iOS client will not include the following key:

• java_versionThe Android SDK will not include these keys:

• java_version• application_version• application_bundle_id• application_build_versionPlatforms built with Java SDK will not include these keys by default:

• application_version• application_bundle_id• application_build_version• device_model

Example Response

{"locale":"en_US","PredixMobileVersion":"1.7.361","SyncGateway":"abc1234.run.aws-usw02-pr.ice.predix.io","server_hostname":"abc1234.run.aws-usw02-pr.ice.predix.io","ContainerVersion":"1.7","database_version":"1.2.1 (unofficial)","device_model":"iPhone","application_bundle_id":"com.ge.ent.PredixMobileReferenceApp","predix_mobile_sdk_version":"1.7","device_OS":"iPhone OS","device_OS_version":"9.3","application_build_version":"1.7","predix_mobile_sdk_build_version":"1.7.361","application_version":"1.7"

}

12 © 2020 General Electric Company

Page 17: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

pm webappsUse this command to list all web apps uploaded to your Predix Mobile service instance.

For example:

$ pm webappsName Version

Channelpm-minimal-app 0.0.1 webapp-pm-minimal-

app_0_0_1OK

pm workspaceUse this command to create a workspace for your project.

pm workspace -c

You can also clone any of the examples found at https://github.com/PredixDev/PredixMobileSDK and thenuse the pm workspace command from within the example's root folder.

© 2020 General Electric Company 13

Page 18: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Predix Mobile Client Core Services Framework

Predix Mobile Client Core Services FrameworkThe Predix Mobile Client SDK provides REST API-based services that add functionality to hybrid and nativemobile applications.

The Client SDK consumer application, the Predix Mobile app container, can interact with these localservices following this general URL structure: http://pmapi//<parameters>.

The Predix mobile app container interprets URL requests and delegates them to the services in the PredixMobile Client Core Services framework , which return a JSON payload describing the result of the call.

Predix Mobile Authentication ServiceThe Authentication service facilitates tasks such as login, logout, and management and validation ofoffline authentication credentials.

The offline authentication web app example shows how to call the service.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Authentication

Method/URL Description

POST http://pmapi/auth Start the authentication process, displaying an offline or onlineauthentication page.

POST http://pmapi/auth/setup Start the offline authentication setup process, displaying theoffline authentication setup page.

PUT http://pmapi/auth/<token>/setup Set up a user's offline password by returning a token to theauthentication setup page.

POST http://pmapi/auth/update Start the offline authentication management process, displayingthe offline management setup page where a user can changethe account password.

PUT http://pmapi/auth/<token>/authenticate

Authenticate a user's offline password.

PUT http://pmapi/auth/<token>/update

Update a user's offline password.

DELETE http://pmapi/auth Cancel a current in-process login or setup, resetting theauthentication service to allow a new POST request.

GET http://pmapi/auth Retrieve the status of the login process using HTTP Statuscodes

Predix Mobile Boot ServiceUse the Boot service to start the app-initialization process in the Predix Mobile Client SDK environment,or to restart an app.

The offline authentication web app example shows how to use the Boot service to initiate an app restart.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Boot

14 © 2020 General Electric Company

Page 19: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Method/URL Description

POST http://pmapi/boot/start Starts the app initialization process. If the user is notauthenticated, the service calls the User Authentication service.If online, the service starts Couchbase replication.

POST http://pmapi/boot/restart Reinitializes the app. The service shuts down the currentrunning Predix Mobile app. It also logs off the user, shuts downCouchbase, and recalls the boot start process.

Predix Mobile Command ServiceUse the Command service to create, modify, and manage commands.

Commands are specific instructions sent to the Predix Mobile service, the Command Processor in thePredix Mobile service pick up these specific instructions for processing.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Command

Method/URL Description

POST http://pmapi/command Create a command with a dictionary of name/value pairsencompassing the command for the Command Processor.

PUT http://pmapi/{commandId} Update a command.

GET http://pmapi/{commandId} Retrieve a command.

GET http://pmapi/command Retrieve all commands.

Predix Mobile Connectivity ServiceUse the Connectivity service to retrieve a device's current connectivity state.

The Mobile Offline Login web app example shows how to use the service to make the call.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Connectivity

Method/URL Description

GET http://pmapi/connectivity Retrieves state of network connectivity and authentication forthe device.

Predix Mobile Data Access ServicesThe Predix Mobile Core Services Framework includes a high-level data access service and a low-level dataaccess service.

Use the high-level data access service (DB) to start replication, query the status of replication, add andretrieve attachments from storage, and to close the database. It also supports basic document retrievaland query by type. The low-level data acess service (CDB) provides the ability to read and writedocuments and is directly connected to the actual storage engine. Typically, you use the high-level servicefor overall storage engine operations and you use the low-level service for direct CRUD operations to thestorage service.

© 2020 General Electric Company 15

Page 20: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

DB (Data Access High-level) ServiceThe DB Data Access high-level service provides local database management services. In addition, itprovides an abstraction layer to simplify data-access interactions such as saving and retrievingdocuments.

The Predix Mobile Sample App shows how to use a Data Access High-level service function to retrieve adocument and its details.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Data-Access-High-level

Method/URL Description

POST http://pmapi/db/databaseName/replication

Start replication and continue as long as the device hasconnectivity and is authenticated.

GET http://pmapi/db/databaseName/replication

Retrieve the replication status.

GET http://pmapi/db/databaseName/document/documentId

Retrieve the document.

POST http://pmapi/db/close Close CB database.

CDB (Data Access Low-level) ServiceUse the CDB service to perform basic data-retrieval and updates for the local document database

This service provides create/read/write/delete document operations and query views. The CDB servicesupports database-level commands rather than server-level commands.

The Predix Mobile Sample App shows how to use the Data Access Low-level service to retrievedocuments.

URL Description

http://pmapi/cdb/databasename/... See the Couchbase Lite REST API documentation for anoverview of the available resources.

Predix Mobile Logging ServiceUse the Logging service to send log output to the device’s logging system.

You send a log message inside a JSON object using a PUT request to this service. The JSON object shouldinclude a log property containing the actual log message, and a log level classification property.

The Predix Mobile Offline Login web app example shows how to use the service to send a log message.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Logging

Method/URL Description

PUT http://pmapi/log Send log output to the logging system.

16 © 2020 General Electric Company

Page 21: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Predix Mobile OpenURL ServiceUse the OpenURL service to open a URL on a device that is external to your app.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/OpenURL

Method/URL Description

POST http://pmapi/openurl Opens a URL on a device that is external to your app.

Example JSON Input

Open the mail app, and start a new message:

{

"url": "mailto://[email protected]?Subject=Hello%20again"

}

Initiate a phone call:

{

"url": "tel:1-800-555-1212"

}

Open Facebook:

{

"url": "fb://feed"

}

Open Page in Safari:

{

"url": "https://www.google.com"

}

Predix Mobile Notify ServiceUse the Notify service to relay event notifications from the client device to the web app, or to alert theuser at a specific time if the container app is not running.

For example, this service can run a JavaScript function in the current web app when the followingconditions are met:

• A specific database document changes.• The application is about to go into the background.

© 2020 General Electric Company 17

Page 22: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

• The device's connectivity state has changed.• The device is currently replicating data with the server.• A specific time has been reached.

The Mobile Send Command web app example shows how to send a POST request to the Notify service fora specific event, DocumentChangedNotification, with a document ID. This event is triggered whena specific document in the data store changes. In the example, the id of the source document is includedin the URL. In this example, gotChanges defines a JavaScript function that is invoked when thenotification occurs. This function is passed as the POST body.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Notify

Event Notifications

Method/URL Description

POST http://pmapi/notify/events/<notificationName>

Subscribe to a notification.

• ReachabilityWatcherNotificationPosted when the Reachability Watcher detects a

connectivity state change.

• DatabaseDownloadNotificationDescribes current download state.

• DocumentChangedNotification/<docid>Describes document changes.

• InitialReplicationCompleteNotificationPosted when the local database has completed its first

replication. After this point, the database is considered up-

to-date and it is safe to store and retrieve data.

This notification is only useful for Container observers, not

web apps. By the time a web app starts, this notification

has already occurred.

See https://github.com/PredixDev/PredixMobileSDK/wiki/

Posted-Notifications.

DELETE http://pmapi/notify/events Unsubscribe from all subscribed notifications.

DELETE http://pmapi/notify/events/<notificationName>

Unsubscribe from <notificationName>.

GET http://pmapi/notify/events Retrieve all currently subscribed notifications.

GET http://pmapi/notify/events/<notificationName>

Retrieve a specific notification.

Predix Mobile User Information ServiceUse the User Information service to retrieve a logged-in user and display that user's assigned dataelements (such as a work item).

The Mobile Sample App shows how to use the User Information service to retrieve user details.

18 © 2020 General Electric Company

Page 23: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/User-Information

Method/URL Description

GET http://pmapi/user Retrieve user information.

GET http://pmapi/user/data-element Retrieve a specified data element for the user.

POST http://pmapi/user Write the user information.

Predix Mobile User Settings ServiceUse the User Settings service to facilitate unencrypted data storage and retrieval on a given device.

Use this service to define user preferences, or to define information that needs to persist when theapplication stops running, but is not security-sensitive or required to be stored in the local database.

Method/URL Description

GET http://pmapi/usersettings/settingkey

Retrieve the user settings based on a setting key.

GET http://pmapi/usersettings Retrieve all user settings.

POST http://pmapi/usersettings/settingkey

Set the user settings based on the setting key.

POST http://pmapi/usersettings Store user settings.

DELETE http://pmapi/usersettings/settingkey

Delete a specified user's settings based on a setting key.

Predix Mobile Version ServiceUse the Version service to retrieve version and device information.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Version

© 2020 General Electric Company 19

Page 24: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Method/URL Description

GET http://pmapi/version Status code 200, data in JSON dictionary form with thefollowing keys:

• predix_mobile_sdk_version: Versionnumber of the Predix Mobile SDK

• predix_mobile_sdk_build_version:Build version number of the Predix Mobile SDK

• application_version: Version number of thecurrent container app

• application_build_version: Build versionnumber of the current container app

• application_bundle_id: Bundle Id of the iOScontainer app

• java_version: Version number of Java

• server_hostname: Configured server hostname

• device_model: Hardware description or device type

• device_OS: Operating system name

• device_OS_version: Operating system versionnumber

• database_version: Couchbase Lite versionnumber

• locale: Current running locale

These keys are provided for compatibility. May be deprecated inthe future.

• PredixMobileVersion: Matchespredix_mobile_sdk_build_version

• ContainerVersion: Matchesapplication_build_version

• SyncGateway: Matches server_hostname

Sample Output

{"locale":"en_US","PredixMobileVersion":"1.7.361","SyncGateway":"abc1234.run.aws-usw02-pr.ice.predix.io","server_hostname":"abc1234.run.aws-usw02-pr.ice.predix.io","ContainerVersion":"1.7","database_version":"1.2.1 (unofficial)","device_model":"iPhone","application_bundle_id":"com.ge.ent.PredixMobileReferenceApp","predix_mobile_sdk_version":"1.7","device_OS":"iPhone OS","device_OS_version":"9.3","application_build_version":"1.7","predix_mobile_sdk_build_version":"1.7.361","application_version":"1.7"

}

Platform Differences

The iOS and MacOS client do not include this key:

• java_version

20 © 2020 General Electric Company

Page 25: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Predix Mobile Window ServiceUse the Window service to manage the display of web apps in the container user interface.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Window

Method/URL Description

POST http://pmapi/window/pane?webapp=appname

Load a specified web app by appname.

If using appname for the API call, your app.json file'sdependencies must contain your web app name andversion. For example:

{"name":

"FunctionalTestSuite","version": "1.0.0",

"starter": "e2e-app-test","dependencies": {

"e2e-app-test": "0.0.1","webapp-pm-minimal-app":

"0.0.1"}

}

POST http://pmapi/window/pane?webapp=appnameID

Load a specified web app by appnameID. Use the pmwebapps command to obtain the ID. For example:

$ pm webapps

NameVersionChannel

pm-minimal-app 0.0.1webapp-pm-minimal-app_0_0_1

OK

POST http://pmapi/window/showseriouserrorpage

Show an error dialog.“”

POST http://pmapi/window/spinner Set the spinner.

GET http://pmapi/window/spinner Retrieve the current state of the spinner.

Predix Mobile Client Advanced ServicesThese advanced services are available only on the iOS platform.

© 2020 General Electric Company 21

Page 26: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Predix Mobile Local Notifications ServiceUse the Local Notifications service to set, retrieve, and delete notifications that are local to a device.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Notify#local-notifications.

Platforms supported: iOS

Method/URL Description

POST http://pmapi/notify/attime Set notification based on local attributes.

GET http://pmapi/notify/attime Get a specific local notification.

DELETE http://pmapi/notify/attime Delete all local notifications.

DELETE http://pmapi/notify/attime/notificationId

Delete a specific local notification.

Predix Mobile Secure Storage ServiceUse the Secure Storage service to facilitate storage and retrieval of data that is persistent in an encryptedstate, possibly requiring authentication to retrieve.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/Secure-Storage

Method/URL Description iOS

POST http://pmapi/secstorage

Post data to storage that is persistent inan encrypted state.

Yes

GET http://pmapi/secstorage/key?prompt=override+prompt

Retrieve data from storage that ispersistent in an encrypted state.

Yes

Predix Mobile TouchId ServiceUse the TouchId service to determine if a device supports biometric fingerprint identification, and if thecurrent owner is the device owner.

Reference documents: https://github.com/PredixDev/PredixMobileSDK/wiki/TouchId

This service is available only on the iOS platform. It is only supported on devices that support TouchID.

Method/URL Description

GET http://pmapi/touchid Determine if the device supports biometric identification.

GET http://pmapi/touchid/validate?prompt=promptstring

Determine if the current owner is the device owner.

22 © 2020 General Electric Company

Page 27: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Configuration Preferences and Properties

Configuration Preferences and PropertiesThe Predix Mobile SDK has two types of on-device configuration storage: Preferences and Properties.Application users can change Preferences on a device, whereas a developer sets Properties at compile-time.

PreferencesPreferences consist of developer-set defaults, user-changeable current values, and a user interface tochange those values.

For iOS, the Preferences defaults are stored in the Mobile applications root.plist file in Xcode. ThePreferences defaults are used to populate the iOS and the macOS’s standard UserDefaults object. IniOS, the user can manipulate those values using the standard iOS Settings app.

For macOS, since there is no standard Settings app, the reference app container includes a Preferencesuser interface that you can mimic to construct your own UI for these values, and then that UI can updatethose values in the UserDefaults object.

For Android, the default values are stored in assets/preference_defaults.properties file inthe application's Android Studio project, and the storage implementation uses the AndroidSharedPreferences object, along with a sample UI provided in the reference app container.

By default, the server endpoint and default logging level is stored in Preferences, however again, this canbe changed using the PredixMobileConfiguration class. The defaults are shown in the tablebelow.

PropertiesBecause properties are set by the developer at compile-time, they are read-only configuration elementsfor users, and are not expected to change.

In the iOS and macOS implementations of the Predix Mobile SDK, Properties are stored in the applicationproject’s info.plist file.

For Android, properties are expected to be in the resources/config.properties file; although thisfilename can be changed by updating the configurationPropertiesFilename property of thePredixMobileConfiguration class.

By default the pm-app name and version configuration is stored in Properties on the iOS, macOS,and the Android implementations of the Predix Mobile SDK. However, this can be changed by updating theappropriate properties in the PredixMobileConfiguration object. The defaults are shown in thetable below.

© 2020 General Electric Company 23

Page 28: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Configuration DefaultsThis table identifies the default key name properties and location properties in the configuration controlclass.

Configuration element Key Name Property Location Property

Predix Mobile app name pmappDocumentNameKey pmappDocumentNameConfigLocation

Predix Mobile app version pmappDocumentVersionKey pmappDocumentVersionConfigLocation

Server endpoint serverEndpointConfigKey ServerEndpointConfigLocation

Logging level loggingLevelConfigKey loggingLevelConfigLocation

Other values may be stored in Preferences and Properties as needed, depending on the platformimplementation. Refer to the exposed properties of the platform’s configuration control class.

Example Configuration Changes

Change App Document Name Key

To change the key used to extract the Predix Mobile app name from configuration from the defaultpmapp_name toPredixMobileAppName:

iOS/MacOSPredixMobilityConfiguration.pmappDocumentNameKey ="PredixMobileAppName"

Android/JavaPredixMobileConfiguration.pmappDocumentNameKey ="PredixMobileAppName";

Change App Name Configuration Location

To change the location used to retrieve the Predix Mobile app name from the default Propertiesconfiguration to the Preferences configuration:

iOS/MacOSPredixMobilityConfiguration.pmappDocumentNameConfigLocation =ConfigurationLocation.settings

Android/JavaPredixMobileConfiguration.pmappDocumentNameConfigLocation =PredixMobileConfiguration.ConfigurationLocation.PREFERENCES;

24 © 2020 General Electric Company

Page 29: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Troubleshooting Predix Sync and SDK for Hybrid

Troubleshooting UAA ServiceThe following are general troubleshooting tips and issues you may experience when using Securityservices.

• Troubleshooting UAA Command Line Interface (UAAC) Installation Issues• Troubleshooting Oauth2 Issues

Troubleshooting UAA Command Line Interface (UAAC) Installation Issues

There are a number of ways you can install UAAC. The procedure lists recommended installation steps forWindows and Linux users.

Windows

1. Install Ruby from http://rubyinstaller.org/downloads.Use the stable version of Ruby (version 2.1.x).

Note: The 64-bit versions of Ruby are relatively new and not all the packages have been updated to becompatible with it. To use the 64-bit version you will require compiler knowledge, and you will need tobe prepared to solve dependency issues.

2. Install the Ruby development kit.Follow the installation steps at https://github.com/oneclick/rubyinstaller/wiki/Development-Kit.

3. Download Gem for UAAC, cf-uaac*.gem, from https://rubygems.org/gems/cf-uaac.4. Install the cf-uaac*.gem gem.

gem install cf-uaac*.gem5. Test if the installation was successful.

uaac help

Linux

Installation of UAAC on Linux or Mac is easier if you use the bundler gem to install all the requireddependencies for cf-uaac gem install.

1. Verify that the Ruby version of Ruby is a stable version (version 2.1.x).

ruby --version2. Download Gem for Bundler, bundler.gem, from https://rubygems.org/gems/bundler.3. Install the bundler gem.

gem install bundler4. Generate a Gemfile with the default rubygems.org source.

bundle init

The Gemfile is created in the same location as the bundler gem.

© 2020 General Electric Company 25

Page 30: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

5. Edit the new Gemfile to include the gems you want to include in the bundle.

# A sample Gemfilesource "https://rubygems.org"

# gem "rails"gem 'nokogiri'gem 'rack', '~>1.1'gem 'rspec', :require => 'spec'gem 'cf-uaac'

6. Install all of the required gems from your specified sources.

bundle install7. Install the cf-uaac gem.

gem install cf-uaac8. Test to see if the installation was successful.

uaac help

Troubleshooting Oauth2 Issues

Predix platform services use OAuth2 for authentication. Errors related to OAuth2 include the HTTP 401Authorization error. To troubleshoot an OAuth2 issue, check the claims in a user or application token.For example, if you receive an HTTP 401 authorization error, you need to make sure that the token wasissued from the correct UAA (iss claim) with the required scopes (scope).

Caution:

Using online tools to decode tokens comes with several risks. If a token is stolen, it can be used byanyone to access protected resources without any other credentials. Even after a token expires,its claims information exposes internal details about Predix applications and systems, which canbe used to help in other attacks.

Use the following tools to decode tokens on your local machine:

• UAACUse the following command to decode a token:

uaac token decode

Example:

uaac token decodeeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovLzEyMzQxMzQzMTI0MTMubXktZG9tYWluLmNvbS9vYXV0aC90b2tlbiIsInNjb3BlIjoidGVzdCIsInN1YiI6ImpvZUBleGFtcGxlLmNvbSJ9.KGzJ12fOqBF2sxi9F3oFG3FDWBmNES9TU2j7yc_XyP0

Note: no key given to validate token signature

iss: https://1234134312413.my-domain.com/oauth/tokenscope: testsub: [email protected]

26 © 2020 General Electric Company

Page 31: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Note:

As indicated in the UAAC output message, you can provide a public key to validate the issuer of thetoken.

• Base64The JWT claims are Base64-encoded JSON. If you do not need to validate the JWT issuer, use a toolthat can decode the token claims section.

A JWT token uses the following format:

base64encoded_header.base64encoded_claims.signature

Use the following command to list the claims:

echo | cut -f 2 -d . | base64 --decode

Example:

~/dev$echo'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovLzEyMzQxMzQzMTI0MTMubXktZG9tYWluLmNvbS9vYXV0aC90b2tlbiIsInNjb3BlIjoidGVzdCIsInN1YiI6ImpvZUBleGFtcGxlLmNvbSJ9.KGzJ12fOqBF2sxi9F3oFG3FDWBmNES9TU2j7yc_XyP0'| cut -f 2 -d . | base64 --decode{"iss":"https://1234134312413.my-domain.com/oauth/token","scope":"test","sub":"[email protected]"}

~/dev$

SSLException while targeting a UAA instance using UAAC

When targeting multiple UAA instances using UAAC, the client is able to authenticate some UAAinstances successfully, but for others it generates an SSLException.

Cause

One probable cause of this issue is your proxy settings. Additionally the versions of UAAC, Ruby, andOpenSSL that you are using do not support a new GE certificate and you need to be able to accept TLS1.2connections.

Solution

As a workaround, you can use the --skip-ssl-validation flag.

Use the following command to check the SSL certificate:

openssl ciphers -v | awk '{print $2}' | sort | uniq

Use the latest versions of UAAC, Ruby and OpenSSL.

© 2020 General Electric Company 27

Page 32: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

UAA User Account not FoundSystem cannot find account while setting up user access to your app.

Condition

When adding a user to authenticate as part of granting rights to use your app using the pm grantcommand, you receive a message that user account is not found.

Cause

The username is not valid.

Solution

When you grant access using the pm grant command, the user name entered must match the useraccount set up in a corresponding UAA instance.

For more information on creating a user in UAA, see Creating Users in a UAA Instance.

User Token Invalid - ExpiredWhen adding a user to use a Predix Mobile app, you receive a message that the user token has expired.

Condition

When adding a user to authenticate as part of granting rights to use your app, you receive a message thatthe user token is expired:

{"error": "invalid_token","error_description": "Invalid access token (expired): ... expired at

Sat Nov 14 15:51:53 UTC 2015"}

Cause

The user has been added, but the token ID (id.url) for the user has expired.

Solution

Use the following pm-cli command to fetch the correct token for the user (where "admin" is theexample user you are trying to add):

uaac token client get admin -s PredixMobile

The command returns the target and context for the user. The following sample shows a successfulresponse:

Successfully fetched token via client credentials grant.Target: https://894c559b-430a-4d10-83e8-b6ded9e46ced. <server path

28 © 2020 General Electric Company

Page 33: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

here> .comContext: admin, from client admin

Authentication Not Valid when Creating User

Condition

When you run the pm-add-developer script to create a developer user on the UAA server and grantsthem access to the pm.admin group, you get an authentication error.

Cause

The user has been added, but the token ID (id.url) for the user has expired.

Solution

Try re-logging into the UAA server, using the standard uaac commands, and then execute the usercreation operation again:

$> uaac target <uaa-server-url> --skip-ssl-validation$> uaac token client get <username>(enter UAA admin password when prompted)

Running pm CLI in Debug ModeUse debug mode to troubleshoot pm CLI commands that produce error messages.

Condition

When running a pm command, you receive an error message.

Solution

Run the command in debug mode.

The following example shows the syntax for running the pm auth command in debug mode:

pm auth --debug user password

You should see output similar to the following:

HTTP-Util:GetResource: request options: {"method": "GET","url": "617421.grc-apps.svc.ice.ge.com/login","headers": {

"User-Agent": "pm-cli 1.0","Accept": "application/json","Content-Type": "application/json"

},"json": true}

© 2020 General Electric Company 29

Page 34: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

In the example above, if you were certain that your credentials were OK, you would check to make surethe URL matches the URL bound to your pm-service.

30 © 2020 General Electric Company

Page 35: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Developing Apps for Apple Devices

Developing Apps for Apple Devices

Build an App with Native iOS ComponentsUse this sample code as a model for creating a native iOS app.

This example shows how to create a native iOS app that is similar to the hybrid issues-tracking Sampleapp. It uses a native UI instead of a hybrid one. Native apps can be used to create entire iOS apps, orcomponents of larger native or hybrid apps that require a particular native look and feed, or forperformance reasons, and so on. This example demonstrates a number of techniques, including creatingdatabase views, calling services from native Swift code, and using properties from the web app documentto determine what native components to load.

To learn how to create a non-hybrid, native iOS app with the Mobile SDK see https://github.com/PredixDev/MobileExample-iOS-NativeIssuesListApp.

Submitting a Predix Mobile Container to the Apple App StoreUse the Apple Enterprise license program to publish apps for general consumption.

About This Task

Many companies that develop mobile software use internal IT groups and procedures to publish apps inthe Apple App Store.

If your app’s audience is exclusively composed of company employees, your company may qualify for theApple Enterprise license program. This program allows you to internally publish apps without goingthrough the App Store and making your app available to the general public. Because an app distributedthrough the Enterprise license program does not get published to the App Store, the app is not subject tothe strict review requirements that public App Store apps must pass. See the Apple developer site formore details: https://developer.apple.com/programs/enterprise/.

If your app is intended for a larger audience than company employees, then it must be published in theApp Store for distribution.

Software development for devices must meet specific Apple iOS requirements. The App Store DistributionTutorial is a key starting point in the Apple content repository.

Follow these general steps to register your app in the App Store:

Procedure

1. Register as an Apple Developer: https://developer.apple.com/programs/.2. Create your app’s bundle ID, App Store distribution certificate, and provisioning profile on the Apple

Developer site.3. Build and sign your app in XCode.4. Create the app entry in iTunesConnect, including your screenshots, description, keywords, support

URL, and any other required information.5. Upload your app binary files to iTunesConnect.

© 2020 General Electric Company 31

Page 36: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Apple reviews your app, generally within two weeks. New apps are automatically published afterapproval.

If Apple rejects your app, the rejection email includes details. You can then address the problem andresubmit.

32 © 2020 General Electric Company

Page 37: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Release Notes

Release Notes

Related Reference

Predix Sync and SDK for Hybrid on page 33

Predix Sync and SDK for Hybrid

Q3 2017 Release

iOS/MacOSUse the zip files for the iOS/macOS framework (v3.5 and v3.4) to create your own containerapplication. The iOS framework is the same as the integrated iOS SDK framework in thePredixMobileiOS project. The macOS framework is the same as the integrated Mac SDK framework inthe PredixMobileMacOS project.

• Introduced hybrid UI database that allows web applications to load faster. Hybrid UI database is anadditional database that contains the hybrid UI pmapp and webapp documents and attachments.These documents and attachments are independently synchronized, and/or stored in theapplication bundle.

• Enhanced security for web apps that need to call the bridge using SSL encryption (secure HTTPsupport).

• Delete method is added to the Secure Storage Service.• Create, Update, and Delete documents feature is added to the database (DB) Service.• Querying views are added to DB Service.• Command Service is added.

Java

The official Predix Mobile Java SDK for use with Java based applications. For an example on how touse this SDK, see the PredixMobileJavaSampleApplication

Note: The Predix Mobile Java SDK is not meant to be used with or as a replacement for the AndroidSDK. If you are developing an Android application, use the Predix Mobile SDK for Android.

• Introduced hybrid UI database that allows web applications to load faster. Hybrid UI database is anadditional database that contains the hybrid UI pmapp and webapp documents and attachments.

• Enhanced security for web apps that need to call the bridge using SSL encryption (secure HTTPsupport).

• Command Service is added.• Bug fixes and performance enhancements.

Android

• Introduced hybrid UI database that allows web applications to load faster. Hybrid UI database is anadditional database that contains the hybrid UI pmapp and webapp documents and attachments.These documents and attachments are independently synchronized, and/or stored in the assetfolder.

• Enhanced security for web apps that need to call the bridge using SSL encryption (secure HTTPsupport).

• Command Service is added.

© 2020 General Electric Company 33

Page 38: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

• Bug fixes and performance enhancements.

pm CLI Updates

• Support for hybrid UI database.• invalidate-session command added to pm command-line tool.• Minor bug fixes and enhancements.

Q2 2017 Release

JavaThe official Predix Mobile Java SDK for use with Java based applications. For an example on how touse the Java SDK, see sample application repo.

Note: The Predix Mobile Java SDK is not meant to be used with or as a replacement for theAndroidSDK. If you are developing an Android application, use the AndroidSDK.

There are several bug fixes and performance improvements in this release.

• Added the ability to apply filters to the push and pull replicators.• Improved support for Java based browsers like JavaFX to interact with the SDK.• Added support for JavaDoc.• Upgraded database support to v1.4 .• Improved handling of replication failures .• Fixed a crash that occurred while using the attime notifications.

iOS/MacOSUse the zip files for the Apple Framework v3.2 to create your own container application. The iOSframework is the same as the integrated iOS SDK framework in the PredixMobileiOS project. ThemacOS framework is the same as the integrated Mac SDK framework in the PredixMobileMacOSproject.

• Added ServiceInvokeNotification and PMAPIRequestHandledNotification tosupport metric gathering.

• Added notifications to provide more information when replication pauses or resumes.• Exposed UserManager to native code for easier access to user information post-login.• Upgraded database support to v1.4• Improved handling of repeated replication failures.

AndroidThe Predix Mobile Android SDK for use with the Predix Mobile Android Container. This release includesseveral bug fixes and performance improvements.

• Added the ability to apply filters to the push and pull replicators.• Added the ability to query the proximity sensor and orientation of the device.• Upgraded database support to v1.4 .• Improved handling of replication failures.• Fixed a crash that occurred when using the attime notifications.• Improved the JavaScript bridge performance.• Fixed a bug that prevented JavaScript bridge requests from executing when a json object passes

as the request body.• Reduced memory consumption.• Low memory warnings are no longer sent as broadcast messages.• Exposed an internal API to allow the developer to wipe the device's local database. This does not

cause data to be removed from the server.

34 © 2020 General Electric Company

Page 39: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

pm CLI UpdatesNew commands added and enhancements to existing commands in pm command-line interface.

• role and conflicts commands are added to pm command-line tool.• role assignment option added to the channels command.• apps/webapps commands are enhanced.

Q1 2017 Release

JavaPredix Mobile SDK framework is now supported on the Java platform, including the Predix MobileClient Core Services Framework on page 14 and the sample hybrid application using JavaFX .

Support for applications built with JavaFX.

Note: The Predix Mobile SDK for Java is not meant to be used with or as a replacement for theAndroidSDK. If you are developing an Android application, use the AndroidSDK.

iOS/MacOS

• Added Filter and Channel replication support.• Exposed DatabaseManager class for basic database interaction from native code.• Added ServiceInvokedNotification to gather basic metrics for requests/responses that

pass through the service router.

AndroidNew sample Android client hybrid application example.

pm CLI updatespm version command added to the pm command-line tool.

Q4 2016 Release

AndroidPredix Mobile SDK framework is now supported on the Android platform, including the Predix MobileClient Core Services Framework on page 14 and the Predix Mobile Reference App Container forAndroid.

Apple iOS and MacOS

• SDK is compiled in XCode 8.3 and updated to Swift 3.• Updated various constants and enums to fit Swift 3 standards.• PGSDKLogger is deprecated. Native logging is supported via a new class: Logger.• Logging under iOS 10+ and macOS 10.12+ (Sierra) uses Apple's new Unified Logging System.• When logging out via /auth/logout, session cookies are automatically cleared. Since /boot/

restart calls /auth/logout this behavior also cascades to restarts.• If the server endpoint changes, the app will automatically reset itself.• Changed handling of application lifecycle events and notifications. These methods are available

through the PredixMobilityManager.applicationDelegates property.• Added documentation markup to code.

Q2 2016 Release

Mac OSPredix Mobile SDK framework is now supported on the MacOS platform, including the Predix MobileClient Core Services Framework on page 14 and the Predix Mobile MacOS Reference App Container.

© 2020 General Electric Company 35

Page 40: Predix SDK for Hybrid - GEA Mobile Reference App Container is a native application that includes the Predix Mobile Client Core Services framework that enables you to load, display,

Example Microservices

• Sample Command Processor (https://github.com/PredixDev/MobileExample-Microservice-CommandProcessor).

• Sample Sync Processor that communicates with Predix Asset service (https://github.com/PredixDev/MobileExample-Microservice-AssetIntegration) .

iOS

• Requires device to have a passcode set by default.• Now optional for container app to post UIReadyNotification.• Simplified application-state event communication from Container to SDK.• Added ability to create full text search views.• Exposed default Type query to CDB service as “views/type” view name.• Updated User Settings service to support JSON objects or JSON fragments.• Added replicationAdditionalPushSettings and

replicationAdditionalPullSettings to PredixMobilityConfiguration to allowcontainers to finely tune additional replication settings.

• Updated SDKto allow passing web app documents as parameters to the container during offlineauthentication.

• Updated SDK to clear PMApp document cache whenPredixMobilityConfiguration.loadConfiguration is called.

• Added the following services to the Predix Mobile Client Core Services Framework:

◦ OpenURL◦ SecureStorage◦ TouchId

• Updated to Xcode 7.3.

Example iOS Services

• Basic native iOS service example (https://github.com/PredixDev/MobileExample-iOSService-Sample).

• Retrieve user's current location in iOS using a service example (https://github.com/PredixDev/MobileExample-iOSService-SingleLocation).

• Barcode scanner implementation for iOS using a native service (https://github.com/PredixDev/MobileExample-iOSService-Barcode-Scanner).

• Camera service implementation for iOS using a native service (https://github.com/PredixDev/MobileExample-iOSService-Camera).

Example iOS Clients

Enhancements for customizing the Predix Mobile Reference App for IOS:

• Store logs in the database (https://github.com/PredixDev/MobileExample-iOS-StoreLogsInDatabase)

• Create a non-hybrid, native iOS app with Mobile SDK (https://github.com/PredixDev/MobileExample-iOS-NativeIssuesListApp).

• Development-time rapid on-device web app iterations (https://github.com/PredixDev/MobileExample-iOS-DeviceDevWebAppUpdater).

36 © 2020 General Electric Company