Chapter 12
Chapter 12
In earlier chapters of this book, we explored examples of how SAP HCP and
SAPUI5 can be used to develop and deploy web applications. Through the
responsive design elements of SAPUI5, those applications can automatically adapt
their appearance to run on a range of browsers and screen sizes; desktop brows-
ers, mobile tablets, and phones are all supported. However, for security reasons,
a browser limits the range of OS features and device access that are granted to a
web application. In many cases (especially on mobile devices) we’ll want our
applications to gather information or to interact with the user in ways that go
beyond what we can accomplish in such a restricted model.
Device OS vendors offer the ability to create native mobile applications to gain
deeper access to the features of each device. Each OS vendor offers unique soft-
ware development kits (SDKs) and a companion integrated development environ-
ment to streamline development on each operating system. Such tools deliver
maximum performance and the highest quality user experience, but they also
come with a hefty learning cost—although that’s not to suggest that they are not
worth the effort. Often, however, the goals for a given application make it highly
desirable to deliver the same functionality on the widest number of device types
possible. This is especially common for internally facing applications if the sup-
porting IT department allows employees to use their personal mobile devices for
work purposes. This “bring your own device” approach has given rise to a num-
ber of frameworks to support a write once, run many programming model.
Many write once, run many systems are available today. Probably the most pop-
ular programming model of this type is called a hybrid container. In this case,
As part of SAP HCP, SAP offers SAP HANA Cloud Platform Mobile Services
(HCPms). SAP HCPms can be used to develop and deploy mobile applications
more rapidly and reliably. In this chapter, we start out with an overview of the
purpose of SAP HCPms (Section 12.1), and then move on to a discussion of Cor-
dova application development, which is important to SAP HCPms because it is the
most popular hybrid container available today (Section 12.2). We then mention
the software prerequisites required to run SAP HCPms, with links to further
detailed information about how to make sure these prerequisites are met (Section
12.3). With these basics out of the way, we dive into the technicalities of SAP
HCPms: First, in Section 12.4, we introduce the most commonly used compo-
nents and explain how to work with them. Then, in Section 12.5, we walk you
step-by-step through the development of a simple hybrid application. Finally, in
1.6, we offer some additional information about adding “true mobile capabili-
ties,” such as offline functionality and push notifications.
Note
Although we will focus on the Android platform, the example application can be run on
iOS and Windows Phone with a little extra effort.
12.1 Overview
SAP HCPms supports two distinct client architectures: true native and hybrid con-
tainer. “True” native applications are developed using a device vendor’s native
IDE and UI frameworks: Xcode as an IDE and Cocoa for the UI targeting Apple
iOS, for example. For true native development, SAP HCPms supplies class librar-
ies to give you access to platform functions. These class libraries are dropped
directly into your IDE project. As we’ll explore in a moment, a hybrid client using
SAP HCPms provides a complete chain of tools and programming frameworks
that builds on the capabilities of the Web IDE and SAPUI5.
SAP HCPms provides capabilities to address common requirements that you will
typically encounter when building mobile applications that are left unaddressed
today by device OS vendors:
SAP HCPms runs within your SAP HCP infrastructure as a subscription service.
Figure 12.1 depicts a typical SAP HCPms deployment, in which the supporting
services reside completely within SAP HCP. SAP HCPms typically consumes data
via OData web services (we’ll explore how OData web services are important to
SAP HCPms when we look at offline operation in Section 12.4.3). SAP HCPms
isn’t particularly fussy about where the web services come from; in SAP HCP, for
example, they might be surfaced directly from an SAP HANA database, or they
might be part of a deployed Java application running in SAP HCP. SAP HCP
deployed web applications won’t often be integrated into an SAP HCPms applica-
tion, but don’t rule that completely out: More complex applications might
include having parts of the mobile application content being served dynamically
from a web application server; HCPms would support that.
HCP
HANA XS Web
Mobile
Databases Services
OData Services
Java
Applications
OData
Push
Notification
HTML5
Applications Vendor
Push
Services
Apache Cordova is a set of device APIs that allow a mobile app developer to access
native device function such as the camera or accelerometer from JavaScript. Com-
bined with a UI framework such as jQuery Mobile or Dojo Mobile or Sencha Touch,
this allows a smartphone app to be developed with just HTML, CSS, and JavaScript.
When using the Cordova APIs, an app can be built without any native code (Java,
Objective-C, etc) from the app developer. Instead, web technologies are used, and
they are hosted in the app itself locally (generally not on a remote http server).
And because these JavaScript APIs are consistent across multiple device platforms
and built on web standards, the app should be portable to other device platforms
with minimal to no changes.
SAP uses Apache Cordova in its purest form (Figure 12.2). The container architec-
ture is not modified in any way, except to make available SAP’s own set of plug-
ins to add SAP HCPms features. Because Cordova is used in this pure state, you
have direct access to an extensive library of open-source plug-ins maintained for
use with Cordova. You can review the current registry of Apache Cordova plug-
ins at [Link]
Web View
CSS JS
HTML5
framework suits your needs. By the end of this chapter, though, you should
understand that SAP has put a lot of effort into making SAPUI5 your UI frame-
work of choice for developing applications using the Web IDE.
SAP has designed a tool chain to automate this process. This sequence of tools
starts with the Web IDE. As with conventional mobile web development, it pro-
vides the JavaScript and HTML editing and preview capabilities. Mobile develop-
ment, however, requires us to build the software for each specific device OS ven-
dor and—for now, at least—requires us to have additional components installed
on our local workstation.
In order to bridge development between the cloud-based tools and your local
machine, SAP introduces a local component known as the Hybrid App Toolkit.
Product names from SAP are sometime less than completely clear to the casual
observer, and we have an example of it in their mobile platform products. SAP HCPms
is derived from the on-premise mobile platform, named the SAP Mobile Platform.
By design, the two platforms share a common client SDK. This shared SDK approach
allows you to focus on the functionality of your mobile application first, without having
to decide whether you prefer an on-premise or cloud deployment until later.
Because SAP Mobile Platform was released before SAP HCPms, this shared SDK is
named the SAP Mobile Platform SDK; that’s the name you should look for at the SAP
Store and SAP Service Marketplace.
왘 The SAP Mobile Platform SDK, which includes hybrid application development
plug-in modules, which SAP often refers to as the Kapsel SDK
왘 Operating system SDKs and simulators for each target device: iOS, Android,
and Windows Phone
왘 A Web IDE subscription with the SAP HCP trial account
왘 The Web IDE Hybrid App Toolkit
We’ll offer a general description of each of these pieces and parts next. The best
source for detailed information on preparing your local workstation for mobile
development with the Web IDE will always be found in the SAP HCP online doc-
umentations set: [Link]
Web IDE
device
Preview
vendor
Companion
Web IDE Hybrid SDK & App
App Toolkit simulators
Your
Workspace
communication
server
Apache
Cordova Your
build Application
script
device
SMP
vendor
SDK
SDKs
Figure 12.3 Web IDE and Hybrid App Toolkit: Previewing and Building Mobile Applications
The installers for the SAP Mobile Platform SDK can be downloaded from the SAP
Store, or, if you are currently an SAP customer, they can be downloaded from the
SAP Service Marketplace. Download links for the SAP Mobile Platform SDK will
be found in the Hybrid App Toolkit online installation instructions.
왘 Android SDK
Follow the instructions found at [Link]
[Link] that explain how to install the standalone SDK tools. The Android
SDK tools are currently available at no cost to you.
왘 Xcode for iOS
Visit the Apple site [Link] iOS
development requires Xcode, Apple’s IDE and development tooling. Xcode for
iOS requires an annual subscription fee from Apple (cost varies by region; it is
approximately $100 per year in the United States). Note that HAT and Cordova
builds require an additional Apple component called the Xcode Command Line
Build Tools, which is packaged in a separate installer found at the iOS Deve-
loper Center site.
SAP HCPms is available as a no-cost subscription within your SAP HCP trial
account. As of this writing, the subscription process requires some manual steps in
order to correctly configure your subscription. You can consult the SAP HCPms
document to find instructions covering the setup steps for an SAP HCPms
subscription: [Link]
SAP_HANA_Cloud_Platform_Mobile_Services.pdf.
The Hybrid App Toolkit is a no-cost download from the SAP Store (visit https://
[Link] and search for “Hybrid App Toolkit”). It includes relatively friendly
setup scripts for both Windows and OS X systems. Each script will verify the
installation and configuration of the components we’ve previously mentioned,
plus a few other prerequisites that are all easy to install.
use, how can they be stored securely? How will the application know what serv-
ers to communicate with? What if the application has just been installed and has
never interacted with your server infrastructure before? What sort of registration
for usage tracking and notification purposes will be required?
It turns out that the SAP Mobile Platform SDK provides a modular approach for
handing all of these interactions. You will be able to add and configure it for oper-
ation with only a few lines of code. For native applications you might develop,
the Login module is supplied as a series of class libraries to your application. For
our hybrid application, it is delivered as a Cordova plug-in as part of the Kapsel
SDK.
cases, as well; for example, you might have a requirement to be able to modify or
even create new data records while disconnected. When you are distributing the
same data across thousands or even hundreds of thousands of devices, the syn-
chronization of such data becomes a daunting task. Different mobile platforms
have taken different paths to addressing these needs. SAP’s approach involves a
degree of simplicity uncommon among many mobile platforms, and it has
evolved from the technology experience gained from earlier SAP mobile plat-
forms, such as Sybase Unwired Platform, Sybase MobiLink, and Syclo Agentry,
which have been around for well over 10 years.
definingRequests = {
"Products": "/Products",
"ProductCategories": "/ProductCategories",
"Suppliers": "/Suppliers"
};
Listing 12.1 Defining Requests Data Structure
This is a simple case, basically indicating “take all elements of all three of these
entity collections and store them for later use.”
However, because defining requests recognize most of the OData query language,
one can get more elaborate, as shown in Listing 12.2.
definingRequests = {
"Products": "/Products?$expand=Supplier",
"ProductCategories": "/ProductCategories“
};
Listing 12.2 Alternative (and Equivalent) Defining Request Showing how OData
URI Syntax can be Used Inside a Request
In this instance, we still retrieve all ProductCategories, but we limit the Supplier
list to only those directly linked to a Product. In this example data model, there is
one Supplier for each Product record. Specifying $expand for related data can be
an especially useful technique to limit the data on the device to only what’s rele-
vant to a few key data rows.
Once the data is provisioned on the device in the cached data store, the store can
be periodically updated from the server using a refresh() call. The SAP Mobile
Platform SDK currently defines no policy for refreshing data—programmatically
or otherwise—so choices about when to call refresh() are completely up to you
as the developer.
You will use OData web-services-style I/O operations to interact with the data
store. In fact, the Offline Kapsel plug-in simply implements the data interface to
the Offline plug-in as a hook function intercepting all JavaScript HTTP interac-
tions; the activator of the hook function is named [Link]().
You typically invoke it once: after the Offline plug-in initialization is complete in
your application. If you are offline for a period of time, then any modifications
are recorded silently and transmitted to the server at the time your application
next calls refresh().
The net result is a remarkably easy-to-program offline interface: You set up your
defining requests, execute them as the application starts, call applyHttpClient(),
and then code your SAPUI5 data mappings in the same manner that you would
while online; reading, updating, creating, and deleting data all works pretty much
the same way as it would for online operations.
Modifying a shared data set across a population of loosely connected systems presents
challenges. Modifying a field in an existing record is relatively straightforward. Creating
a new record involves some subtle points, though, and you will want to be aware of
such points, including the following:
왘 The OData services you access will often wrap traditional SQL data tables.
왘 It is quite common for SQL databases to own the responsibility of automatically gen-
erating a primary key at creation time to identify each new row.
왘 If you generate a new record at a device while disconnected, then you have no way
of consulting the server to obtain a generated primary key.
In order to deal with the previously mentioned situation, there is an extra, essentially
hidden column created for each table in the device’s UltraLite SQL storage. This column
is named lodata_sys_eid, and is populated with a unique record ID for each row. This
ID value is private to the local device.
With this mechanism in place, there is no need to supply a Key field for a record when
you create one. In effect, the Offline API uses the lodata_sys_eid column as the
table’s primary key for local reference on the device. This hidden column in each table
is also used to provide foreign key linkage between tables.
There are more features of the SAP HCPms Offline module that you’ll want to explore
on your own. For example, your application can define global characteristics for defining
requests, including specifying details of how defining requests should be processed and
even marking some data collections as “shared” and cached at the server to reduce
backend resource impact. You will find more details on these capabilities in the SAP
HCPms online documentation: [Link]
f5/a25877c16f4fc384c44fcf0b92dab8/[Link].
In this section, we will use this example to explore how the Web IDE leverages
destinations, project templates, and other features to streamline the creation of a
first-order application. We’ll get the basic application running in order to under-
stand the tools, and then we’ll expand the capabilities of the app in subsequent
sections to add interesting capabilities that we can only have in a mobile applica-
tion.
To deploy this web service in your SAP HCP trial landscape, follow these steps:
1. Visit the SAP HCP Cockpit and click on Java Applications on the left-hand tab.
Click on the Deploy Application button. You will see a dialog that looks some-
thing like Figure 12.4.
2. Click on the Browse button. Navigate to the ESPM_V1.war file in the Chap-
ter12/Example12_01/ code samples directory.
3. Enter “espm” as the Application Name.
4. Click on Deploy. It typically takes several minutes to deploy the application
into the SAP HCP landscape and have it readied for use. Upon completion of
that process, you should see a screen resembling Figure 12.5.
5. Click on the espm link. Scroll down to the Application URLs section and click
on the link you see in that section (it should end with “/ESPM_V1”; see Figure
12.6).
Figure 12.6 ESPM Web Service Application Status Display (with Application URL Shown)
6. When you click on that link, you should see something like what’s shown in
Figure 12.7 in your browser. At this point, you are viewing the [Link] file
that was deployed along with the web service. It includes a couple of handy
links (Figure 12.7).
Figure 12.7 The Welcome Page for the ESPM Web Service
7. Click on the Service Document link. You should see something like what’s de-
picted in Figure 12.8.
Figure 12.8 The OData Service Document for the ESPM Web Service
With these steps completed, you now have a self-contained database and OData
web service available as the base for building your mobile application. This web
application will prepopulate itself with a few hundred test records each time it is
initialized. Because this web service is private to your SAP HCP trial account, you
will be able to modify data any time you like without disrupting other users.
12.5.2 Creating an SAP HCP Destination for the ESPM OData Service
In order to use this service within the Web IDE, you will now need to use the SAP
HCP Cockpit to create a new destination. The procedure for creating destinations
is described in Chapter 7, Section 7.3.3. For the destination you are creating,
enter the following information:
Once you save the configuration, it should closely resemble Figure 12.9.
Figure 12.9 The SAP HCP Destination Definition for the ESPM Web Service
Figure 12.10 Web IDE’s Optional Plug-Ins Configuration (from Web IDE 1.9.3)
It’s a fairly common pattern in an application to start with a list of some type of
data (customers or products, for example), to display that data in a list, and then
to allow the user to drill down into the details of an item by selecting it. The Web
IDE Hybrid plug-in provides a Master Detail Kapsel Application template that will
generate that UI pattern with all the extra parts required to drop it into a hybrid
container mobile application.
In order to kick off the process of generating your application from the Master
Detail Kapsel template, follow these steps:
1. From the Web IDE menu, select File 폷 New 폷 Project from Template.
2. From the Categories dropdown (Figure 12.11), select SAPUI5 Mobile Appli-
cations.
3. Select SAP UI5 Master Detail Kapsel Application. As you select a project tem-
plate, notice that there’s a thumbnail view of the application shown on the
right side of the wizard.
4. Click Next.
The preceding steps are just the start. You’ve named the new project, but the new
project wizard will take you through several more steps. Next, you will connect
the application to your products data and map that source data to the template
application.
Figure 12.12 The Data Connection Wizard Step: Connect to Your Web Service
After these values are entered, click Next twice to complete the template wizard.
Note
Replace <your-id> in the SAP Mobile Platform server hostname with your SCN user ID.
After entering all of this information, click on Save. There’s a bug in the current
version of Web IDE’s plug-in, which raises an error claiming that SAP HCPms is
not currently supported. If you click on Save again, the server name will be high-
lighted in red, but the setting will be stored properly for use in your project.
and fault-isolation tasks, such as allowing the inspection of log files. It even pro-
vides a client service to remotely control logging levels in device applications and
to remotely harvest client application logs.
At this point, the cockpit will return you to the Application Details for your new
Products application. A red flag will be shown next to the Application ID, indi-
cating that the application configuration isn’t quite complete (Figure 12.17).
To fix this, click on Backend and fill out the form with the following values:
Click Save.
Note
Due to a defect in the current release of SAP HCPms, the backend URL must include the
HTTPS port number (443), in addition to using the https:// protocol indicator.
You have now supplied enough information in the application definition that it is
ready for use. There are no further steps to take in the SAP HCPms Cockpit; once
the application is configured properly, it is active and ready to service requests.
Note: New Project Templates Are Evolving Quickly in the Web IDE
SAP’s development teams are constantly improving and adding to the features in many
of the Web IDE’s new project templates. An updated version of the Web IDE is being
released to the developer community every month.
if ([Link] || getUrlParameterName("companionbuster")) {
[Link]();
}
else {
startApp();
}
Listing 12.3 Conditional Code Supporting Both Startup Modes
In effect, having this conditional code in place preserves the ability to use the
Web IDE preview as well as to deploy the application in your hybrid container.
This proves to be a handy feature, so you will generally want to leave this code
untouched.
SAPUI5 supports defining views using your choice of either an XML structured
language or by simply defining the view using JavaScript code. This wizard gen-
erates the views as XML definitions. If you plan to create any SAPUI5 views, then
you must limit yourself to XML-defined views in any place you plan to use the
Visual Layout Editor in the Web IDE.
Our list of products is the Master view; open view/[Link] and examine
the contents, shown in Listing 12.4.
<mvc:View
...
<Page
id="page"
title="{i18n>masterTitle}"
>
...
<List
id="list"
items="{/Products}"
... >
<items>
<ObjectListItem
type="{device>/listItemType}"
press="onSelect"
title="{Name}"
number="{Price}"
numberUnit="{CurrencyCode}"
>
</ObjectListItem>
</items>
</List>
...
</Page>
</mvc:View>
Listing 12.4 The List (Master) View Definition View
If you are well-versed in SAPUI5, you are probably comfortable editing these
XML view definitions by hand. If you aren’t yet, then the Web IDE provides a
Visual Layout Editor. You can get a feel for how that operates by right-clicking on
the view/[Link] file name and choosing Open with 폷 Layout Editor (Fig-
ure 12.18).
Figure 12.18 Web IDE’s Visual Layout Editor (Master View Shown)
Internationalization Constructs
Internationalization support in an SAPUI5 hybrid application works exactly as it
does for a conventional SAPUI5 web application. Internationalized text strings
are localized in files in the project’s i18n folder. The default values for all strings
are set in a file named i18n/[Link]. The contents of this file are
shown in Listing 12.5.
masterTitle=
detailTitle=
notFoundTitle=Not Found
notFoundText=The requested resource was not found
masterListNoDataText=No entities
masterSearchPlaceholder=
masterSearchTooltip=
It’s worth noting that there is a minor bug in the current Master Detail Kapsel
template, which leaves the title bar of both the Master and Detail views blank.
The masterTitle and detailTitle properties in this file should have been
assigned values, but they were not. You can fix that problem while you’re visiting
this file. Change the masterTitle and detailTitle properties as follows:
왘 masterTitle=Products
왘 detailTitle=Product Details
masterTitle= Productos
detailTitle= Detalles
notFoundTitle= Extraviado
notFoundText= No se encontraron los datos solicitados
masterListNoDataText= No hay entradas
masterSearchPlaceholder=
masterSearchTooltip=
Listing 12.6 A Sample Spanish Localization Message Bundle File
Similarly, if you wanted to provide a localized version of the strings for British
English, then you’d populate a file named messageBundle_en_GB.properties. You
This live preview mode (Figure 12.19) executes directly in the browser, so it
starts quickly. It does have limitations, though.
Because it runs in the browser, the JavaScript code that executes within your
application will not have access to the full Cordova and SAP Mobile Platform SDK
programming models. Based on that limitation, live preview mode is often best
suited to a quick verification of UI layout.
In order to test or run the application on a device or simulator, you must first start
the Hybrid App Communicator in a shell window (Figure 12.20). The Communi-
cator command script is [Link] for Windows and [Link] for OS X. After starting
the Communicator, you are free to minimize this terminal command window.
Any messages related to the commands you run will be directed to the Web IDE
console.
Figure 12.20 Running the Hybrid App Toolkit Communicator (OS X Terminal Window Shown)
You will also want to start the Android Monitor application ([Link]
[Link]/tools/help/[Link]). This application is supplied as part of
the Android SDK distribution. It is located in a subfolder named tools within
your Android SDK home folder. Simply double-click on the monitor executable
file found in that folder. The default layout of the application will look something
like Figure 12.21.
Figure 12.21 The Android Device Monitor (OS X Main Window Shown)
왘 Running DDMS
This tool gives you complete access to the device or simulator’s message logs.
Console messages you add to your application will be displayed in DDMS.
You must define a new Android device emulator configuration to test your appli-
cation. To do so, proceed as follows:
1. From the menu bar, select Window 폷 Android Virtual Device Manager (Fig-
ure 12.22).
2. You will likely be starting with a different set of AVDs. Click on the Create but-
ton; we’ll go through the steps required to create a phone emulator compatible
with the SAP Mobile Platform SDK. Enter the values as shown in Figure 12.23
and click on OK.
3. Back in the AVD Manager, select the AVD you just created and click on Start.
Most emulators will take a few minutes to start. Once the emulator starts, you
will typically see an Android lock screen. Once you unlock the device, you will
see something like Figure 12.24.
With an Android emulator instance created using AVD, you can now deploy your
application to the local workstation, then build and run it in this emulator.
Within Web IDE, right-click on the hybrid project and select Run 폷 Run On 폷
Android Emulator; the application will be built as a Cordova application,
installed and executed on the emulator.
The SMP Kapsel SDK supplies an Offline plug-in, which connects to the hybrid
container’s web services layer. At a high level, it operates as follows:
왘 The first time your application runs, it cooperates with the SAP HCPms server
to provision your application with any data that it might need to access when-
ever it is offline.
왘 It maintains that cache of structured data, called a store, in an SAP UltraLite SQL
database.
왘 It tracks any records you change, create, or delete while disconnected.
왘 It manages a refresh operation. Once you are reconnected to the SAP HCPms
server and invoke refresh(), client-side modifications are sent to the server,
and changes at your system of record are sent down to the client to update the
application’s cache store.
왘 It maintains an error table in the store to record any client changes that could
not be applied to a backend system for whatever reason.
왘 It connects into your hybrid application directly at the web services access
point, making most of these interactions transparent to an SAPUI5 program-
mer.
1. In [Link], starting at line 21, add the bolded lines shown in Listing 12.7.
<script type="text/javascript" src="[Link]"></script>
<script type="text/javascript" src="dev/[Link]"></script>
<script type="text/javascript" src="dev/[Link]"></script>
<script type="text/javascript" src="dev/smp_helpers.js"></script>
<link rel="stylesheet" type="text/css" href="css/[Link]">
<script>
// OFFLINE
definingRequests = {
"Products": "/Products",
"ProductCategories": "/ProductCategories",
"Suppliers": "/Suppliers"
};
// END of OFFLINE
function getUrlParameterName(sParam)
{
var sPageURL = [Link](1);
var sURLVariables = [Link]('&');
for (var i = 0; i < [Link]; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return true;
}
}
return false;
}
// OFFLINE
onRefresh: function() {
refreshStore();
},
// END of OFFLINE
Listing 12.8 Updates to the Master Controller Module (inserted lines in bold)
Listing 12.9 Additions to the Master View Definition (Added Lines in Bold)
Apple
(Android)
Microsoft MPNS Configuration
Microsoft
Your Network
SAP HCPms acts as a router of push notification messages. In order to utilize push
notifications, you only need to register your intent to use push notifications with
the applicable device vendors and then add the registration information and ven-
dor API keys into your existing SAP HCPms application definition. At that point,
there’s a single REST web services API exposed by SAP HCPms to send a message
to one or more users of an application.
Google Cloud Messaging supplies the infrastructure for push notifications on Android
devices. This is a proprietary service that will be present on any physical Android device
and will also be available on an Android emulator that you have specifically configured
to run the Google APIs. An emulator configured to run the conventional Android APIs
will not be able to receive push notifications.
You must be signed on to the device or emulator with a valid Google ID to receive push
notification messages.
Let’s add push notification support to your HCPms application (Figure 12.26).
First, you will configure push in the server definition of the application. After you
add support at the server, you’ll have to make some changes to the existing client
application source code to complete the process. Finally, you can test the push
notifications in the application.
Apple
Android
Your Servers HCP Mobile Services Push
Notification
REST Your SMP Application Client
service Definition
call Google
Your
Application
Microsoft
Figure 12.26 Push Notifications Rely on Settings in Your SAP HCPms Application Definition
Once again, we’ll limit what we’re setting up to Android, because developing for
Android devices is supported by both OS X and Windows development
machines.
4. On the following panel, locate the Role row marked Notification User. Click
on it to highlight it (Figure 12.28).
5. Click on the Assign User… link. In the dialog box, enter your SCN account user
ID and click on Assign.
Now you will need to register your application with Google API Services and
obtain a server API key. This procedure is outlined ahead. Detailed instructions
can be found at the Google Developer site: [Link]
gcm/[Link]. Proceed as follows:
Note
The sender ID should be the project number assigned to your API project by Google.
<script>
// OFFLINE
definingRequests = {
"Products": "/Products",
"ProductCategories": "/ProductCategories",
"Suppliers": "/Suppliers"
};
// Your sender ID for Android push is the project number
// (not project ID) associated with your Google API project
// see [Link]
GCMSenderID = "999999999999";
// END of OFFLINE
Listing 12.10 Adding the Google Sender ID to [Link] (added code in bold)
Add this code, using your Google project number as the sender ID. Click on Save,
then Deploy 폷 Deploy to local Hybrid App Toolkit.
The simplest way to test the push messaging is to manually compose and send a
REST PUSH API call directly to your SAP HCPms server. This is most easily done
using a Chrome REST API client plug-in called POSTMAN (Figure 12.30).
You can consult the SAP HCP development documentation for details on how to
send a push notification message, but the following is an overview of the steps:
Figure 12.30 POSTMAN, a REST API Testing Client for Google Chrome
12.7 Summary
In this chapter, you’ve seen how combining SAPUI5, the SAP Mobile Platform
SDK, and Apache Cordova in a mobile programming model yields an effective
way to run applications on multiple devices types from a single source code base.
SAP HCPms and the Web IDE, in particular, provide a rich set of tools to stream-
line the mobile development process.