Using Predix Mobile Services to Create a Cross-Platform App

Igor Razhnov


This post introduces developers to Predix services. The scenario for the article includes preparing a simple cross-platform application based on the Cordova technology as well as interacting with Predix Mobile services. We also want to see if there any restrictions for using Predix Mobile services in a hybrid application.



To follow my examples, you need:

  • Node.js
  • the Cordova CLI
  • the Cloud Foundry CLI
  • the Cloud Foundry UAA CLI
  • the Predix Mobile CLI

Find more information in Predix docs.


Creating a cross-platform application

After you install Cordova, create a Cordova project and add platforms you want to test. I used AngularJS to write my sample JS application.

In our case, it is not necessary to deploy the application to Predix: the application will be located on a mobile device. Of course, you can deploy your application to the PaaS and use it via browsers.

At the same time, you need to take care of Predix Mobile services that your application will communicate with. Next, we will focus on how to prepare Predix to serve your application requests.


Communicating with Predix Mobile services from an application

The implementation of the JS code for using Predix Mobile services is the same as you need in a RESTful application. You have to be able to make POST or GET requests. Find the sample code here.


Using Predix Mobile services

To make a valid request and get data from Predix services, you need to create a service instance and then bind it to your application.

To show what services are available for your application, run the following command:

cf marketplace

As a result, you get a list similar to the one on the screenshot below.


With the cf create-service service_name plan my_instance command, create a service instance for your application:

cf create-service log-stash-1 free myapp-log-service

The next step is to bind the new service to your application using the cf bind-service your_app_name service_instance_name command:

cf bind-service testhw myapp-log-service

To update your environment and put the changes into effect, run the following command:

cf restage app_name

Use the command bellow to show your configuration information about included services:

cf env app_name

For example, the VCAP_SERVICES environment variable is shown on the image below.


The next step is to set up access to Predix services for making your requests.


Accessing Predix services

For this step, I use Predix tutorials as a guideline. You can find the details in Exploring Application Security: Create a Predix Service and set up a UAA ClientId.

Here is the section that you need.


My goal is to consecutively execute tasks from the following menu:


I’ll try to explain why this is necessary. Working with Predix Starter Kit, you create users who have access to services you bind to an application. In the Update Client menu, you paste authority-token to add new authorities for accessing Predix services to your client.


Without this manipulation, a user can’t get data from the service even with a valid token. You can input a queue of tokens for several services. Mark them with quotes and separate with spaces.


Now, you are ready to do a request to fill an asset. Use the Predix form to make a test request.


The sample Predix documentation has a mistake: the locomotive endpoint in the URL should be plural—locomotives.

Note: The body of a POST request should be wrapped in square brackets.



I didn’t find any obstacles for creating cross-platform applications using Predix Mobile services during my experiment. However, when working with Predix, you do need to care about managing Predix services and binding them to your application.

Related reading:

About the author: Igor Razhnov is a front-end engineer at Altoros with a strong background in JavaScript and ActionScript development. Having a long record of projects, he has become proficient in using Adobe Photoshop, Adobe Flash, Adobe Illustrator, Adobe Premiere, IntelliJ IDEA, WebStorm, and other technologies as his professional tools.

For the next parts of this series, subscribe to our blog or follow @altoros.

Get new posts right in your inbox!

  • Michael Hart

    Igor, Thank you for your article on Predix Mobile. As the service owner for Predix Mobile I appreciate the focus on how to build mobile applications using the service. You touched on a few points about what Predix Mobile offers as a service and SDK but missed a key aspect of the platform in that we built the service and SDK with a focus on what is required in an Industrial Internet Mobile application. A major requirement is that Industrial Internet Mobile applications need to work all the time even when there is no network connectivity. We made a conscious decision to not build it on Cordova because we wanted to build in the offline capability into the container and simplify the architecture and align with the current microservice principles.

    I would like to offer to work with you on a followup blog post that highlights more of the details on Predix Mobile

    Best regards,
    Michael Hart
    Service Owner – Predix Mobile
    Predix Platform

    • Igor

      Hi, Michael! It’s great to hear that my post was of interest for you. I’m diving into the Predix platform for building mobile apps and trying to analyze it from different angles. So, I’d be glad to learn about your thoughts, get useful insights from you, and work together on a detailed follow-up article. I’d suggest having a call sometime next week—I’ll send you an e-mail to arrange further discussion.

  • Gary Liu

    Hi Igor, so you don’t use the pm scripts which suggested in the Predix mobile tutorial ? we are facing trouble with the scripts

Benchmarks and Research

Subscribe to new posts

Get new posts right in your inbox!