Sie sind auf Seite 1von 89

Introduction to Kii Cloud

Kii Cloud is an MBaaS (Mobile Backend as a Service) and an IoT (Internet of Things) cloud
platform provided by Kii Corporation.
MBaaS is a cloud service that provides various server-side functions as versatile APIs for
mobile apps and IoT solutions. By leveraging these APIs, you can provide services making
your mobile apps and things Internet-ready without the server-side implementations and
operations.
Devices which are part of IoT solutions are called things in the Kii Cloud environment.

Development with Kii Cloud


To provide a service which involves server-side processing by using conventional
development techniques, the developer had to implement server-side functions and operate
servers by themselves.
Kii Cloud has published server-side functions as versatile APIs on the cloud. With Kii Cloud,
you can provide Internet-enabled services by developing only client-side functions. You can
concentrate on developing the service itself and make it more attractive.

Service Structure
The figure below illustrates the structure of a typical service using Kii Cloud.
The developer implements mobile apps and things basically by incorporating the SDK
(Software Development Kit) library provided by Kii. You can easily call the Kii Cloud APIs
by using the SDK.

 The SDKs for mobile apps are available for Android, iOS, and JavaScript.
 The SDKs for IoT solutions are available for Android, iOS, JavaScript, and C (real-
time OSes and such).

Note that you can directly call the Kii Cloud APIs over HTTPS without the SDK as the API
specification is open to the public. You can also use the third-party SDKs.

You start development with Kii Cloud by creating a dedicated application area on the cloud
through the developer portal. You can provide various features by having clients access the
same application on Kii Cloud. Such features include data sharing among mobile apps and
remote operation of things in IoT solutions.
Advantages of Using Kii Cloud
Kii Cloud gives you various advantages. This topic describes its advantages from the
following five points of view.

 Decreased Development Cost


 Low Overhead of Operation
 Clear Boundary of Responsibility for Security
 Business Development through IoT
 Improved Quality of the Service and the Team

Decreased Development Cost


Kii Cloud eliminates the need for server-side development.
To make your mobile apps and things Internet-ready by using conventional development
techniques, you had to set up servers. There are a lot of tasks to be done before the release,
such as designing the protocols and APIs, adjusting the specification, and implementing the
server program. In addition, those tasks require different expertise from that for the
development of mobile apps and things.
Kii Cloud has made its APIs for server-side functions open and versatile with its cloud
technologies. You can immediately use those APIs on your mobile apps and things. You can
make your mobile apps and things Internet-ready at a low cost and in a short period of time
by developing client-side functions only.

Low Overhead of Operation


Kii Cloud frees you from server operation during the period of the service offering.
End users can use your mobile app once you develop and deploy it. By contrast, the server
functions require 24/7/365 monitoring and emergency management until the service is
discontinued.
It is a huge burden to maintain the operation team which is responsible for tasks as below for
every released service.
 Prompt troubleshooting: Retain engineers who know the unique server specification
well for prompt troubleshooting.
 Load balancing of servers: Balance server workload based on the changes in the
number of users.
 Applying security patches: Monitor the security patch status of the deployed OSes
and middleware and fix problems in patch application immediately.

With Kii Cloud, these operational tasks are managed by the dedicated server engineers of Kii.
They always monitor the status of the service operation and take necessary actions. So, you
can minimize risks after releasing your service.

Clear Boundary of Responsibility for Security


With Kii Cloud, you can use server functions without bearing the responsibility for server
security. You can build your own internet service and rely on Kii for server security.
The security of Kii Cloud as a platform is not deteriorated when you customize the server-
side processing on Kii Cloud by using measures like the server extension feature. By contrast,
with a service like VPS (Virtual Private Server) for example, inappropriate management of
the database installed on the server can cause security deterioration. On this point, your
responsibility for security is limited with Kii Cloud as compared with other services.
Note that you are responsible for the security at the application level. For example, suppose
you implement a function to execute server code which accesses data with the administrator's
privilege. If you allow anonymous users to access this function, it would cause risks of
unauthorized use of the function and information leak. See Security for security
considerations.

Business Development through IoT


Kii Cloud facilitates the integration of hardware devices into your IoT solutions. You can
quickly link existing products with mobile apps and leverage data on the cloud for business
development.
Hardware products tend to be rated from the aspects of performance, precision, quality,
pricing, and so on. As products in the market have reached a certain level of maturity in terms
of these aspects, it is hard to stand out in the existing highly competitive market.
You can create new added values and compete in the market by linking various products with
mobile apps via Kii Cloud. Also, there are possibilities of new businesses in leveraging data
accumulated on the cloud from mobile apps.

Improved Quality of the Service and the Team


Kii Cloud helps to improve the quality of your service itself. Moreover, Kii Cloud can be a
trigger to build a strong development team that can act vigorously, aiming to improve the
service quality.
If you plan to implement the server-side processing by yourself, typically, the server team
and the client team decide the protocol specification at the beginning. Then, the teams
develop and test the service according to the specification. This organizational structure
might leave the team members to give the highest priority to compliance with the
specification. They might work towards safe completion of the project as a matter of first
priority, rather than placing importance on usability and functionality of the service.

With Kii Cloud, basically, you do not need to form the server team. In other words, the client
team can independently control the entire service specification. The team can concentrate on
improving the service through trial and error for new ideas because the server-side functions
are always available as versatile APIs. This workflow should make the service more useful
because the team can reflect ideas to the specification in a later stage of the project.

As for the aspect of team behavior, deployment of Kii Cloud can transform the team by
shifting from reactive to proactive development, creating values with determination for better
quality instead of mere programming just to comply with the specification. Kii Cloud can
make the team more vigorous with a focus on quality.
Mobile Features
Use the Kii Cloud SDK when you make your mobile apps Internet-ready without the IoT
features of Kii Cloud.
If you use the IoT features, Kii recommends using Thing Interaction Framework introduced
in IoT Features. Still, the Kii Cloud SDK can be used to fine-tune the IoT features.
This section outlines the following subjects of the Kii Cloud SDK.

 Objects
 Buckets
 Users and Groups
 Scopes and Access Privileges
 Push Notification
 Server Extension

This section provides only the overview. See Function Guide for the functional details
and Programming Guides for programming implementation.

Objects
A piece of data on Kii Cloud is called an object. The mobile app can save and get data in Kii
Cloud with objects.For example, you can provide a service to share photographs between two
martphones as below.
An object can store the following two types of data:
 JSON Document
You can store any JSON document in an object. The Kii Cloud SDK accesses JSON
fields as key-value pairs.
In this example, the title of the photograph title and the photographer takenBy are
represented as a JSON document.
 Object Body
You can attach a large size of binary data such as a file to an object. This binary data
is called an object body. An object body is optional.
In this example, image data are stored as object bodies.
According to the requirements of your service, you can freely determine the format of the
JSON document for each object type and whether an object body should be attached to an
object or not. The mobile app can immediately upload objects to Kii Cloud because it is
unnecessary to define type information (schema) in advance, unlike relational databases.
Kii Cloud automatically indexes the top level items of JSON documents for search. For
example, you can execute a process to search for objects whose takenBy is Bob
James through a few dozens of thousands of objects at a low load.

Buckets
You use buckets to organize the usage of objects in Kii Cloud.
A bucket stores objects. It is similar to a directory in a file system except that a bucket does
not have any hierarchy. A bucket can be referenced by name.
In the below example, objects are registered in the two buckets: PhotoData for images
and ViewSetting for user settings.
You can freely define buckets so that the mobile app can easily manage them. Numerous
objects, which will be generated according to the specification of the mobile app, can be
categorized with buckets. You can get objects in buckets by ID and search queries.

Users and Groups


You can manage users and groups in Kii Cloud.
Basically, one user corresponds to one end user of the mobile app. An appropriate level of
security is ensured by registering and authenticating users to Kii Cloud to identify users
accessing data.
A group is a collection of users. You can easily manage data shared among multiple users
with groups.
The below figure illustrates how Kii Cloud maintains groups in services like an SNS. Users
and groups have N-N relationships.

Kii Cloud provides various login methods as follows:

 Login with username, phone number, and email address


 Login with credentials for external services such as Facebook and Twitter
 Login by the pseudo user feature. Pseudo user information is associated with and
maintained on a device, eliminating the need for specifying username.

Scopes and Access Privileges


Buckets are managed in the three scopes: the application scope, group scope, and user scope.
 Application Scope
Buckets in this scope belong to the application. These buckets are suitable for data
shared by all the users of the application, such as the highest score of a game and
default setting values.
 Group Scope
Buckets in this scope belong to a group. These buckets are suitable for data shared by
group members, such as data on a bulletin board.
 User Scope
Buckets in this scope belong to a user. These buckets are suitable for data privately
owned by a user, such as a user's personal data and setting information.
You can create multiple buckets per user or group instance in each scope. Each bucket can
store multiple objects.
In the below example, each user has two buckets, PhotoData and ViewSettings . Suppose
you need to display all the images owned by Bob James . You can get the data of Tokyo
Sta. and Maldives by calling the API which lists objects in the PhotoData bucket of the
user Bob James .
Buckets and Access Privileges
Access to buckets in each scope is determined by the access privileges of the logged-in user.
In the below example, the logged-in user Bob can access the following data:

 Buckets in Bob's user scope


 Buckets of Sales division that Bob belongs to

 Buckets in the application scope


Kii Cloud returns an error if Bob attempts to access buckets other than the above.
Buckets and objects have their own ACL (Access Control List) which is a whitelist
containing users who can access them. You can change the access rule by updating the ACL.

Push Notification
With Kii Cloud, you can easily configure push notification to immediately notify devices of
changes on the server. You can use FCM (GCM), APNs, JPush, and/or MQTT (over
WebSocket or the TCP socket), depending on the device platform.
Kii Cloud has three types of push notification. Especially, the Push to User notification
serves for various purposes.
See the below figure for an example. User B can send a push notification to User A to
notify that User B has updated an object on Kii Cloud. User A can receive the message via
a push notification network by subscribing to a topic.
Just like buckets, you can create multiple topics in each of the application scope, group scope,
and user scope for different purposes.
Other than the above, you can use the Push to App notification which notifies of all the
changes in a certain bucket and the Direct Pushnotification which allows the administrator to
directly send push notifications to users.
The push notification feature of Kii Cloud is supposed to be mainly used for notifications
between devices. Broadcasting to numerous users for marketing and so on is not
recommended because you will not get desirable performance.

Server Extension
Kii Cloud has the server extention which allows executing any JavaScript programs on the
server.
Deploy server code written in JavaScript and a server hook configuration file to Kii Cloud
with the command line tool. You can call the deployed server code from the mobile app
and/or automatically execute it when a certain time arrives or specific data is updated.

You can use server code for various tasks such as executing a process on the server to prevent
reverse engineering, adjusting data on the cloud with the administrator's privilege, and so on.
Next Step
The following contents are available for you to deepen the understanding of the features for
mobile app development.
 Function Guide
We recommend you to read this section if you are considering about using the Kii
Cloud.
The section summarizes the overview of the major features for mobile app
developments. The section also presents the advantages of using these features.
See Function Guide for more information.
 Sample code: Hello Kii
If you are a developer, we recommend you to read this section.
Hello Kii is designed to walk through the usage of the Kii Cloud SDK. Use this
sample as a reference if you develop mobile apps or plan to fine-tune your IoT
solution with the Kii Cloud SDK.

See Hello Kii for more information about the sample codes.
See Programming Guides for more detailed feature explanation for developers.
IoT Features
Use Thing Interaction Framework and the Kii Cloud SDK when you build IoT solutions.
 Thing Interaction Framework is a framework positioned above the Kii Cloud SDK. It
is a combination of selected functionalities of the Kii Cloud SDK to accelerate IoT
solutions. The Thing-IF SDK is the SDK to use this framework.
 The Kii Cloud SDK provides IoT elements such as thing management as well as the
features described in Mobile Features.
The Kii Cloud SDK allows you to combine various functional elements for the mobile app to
deliver necessary functionalities. In contrast, Thing Interaction Framework has predefined
usage models and provides necessary features based on the models.
Use Thing Interaction Framework for efficient implementation. If the models of Thing
Interaction Framework do not satisfy some of your requirements, you can develop the
missing functionalities by combining functional elements of the Kii Cloud SDK.

This section outlines the following subjects with a focus on Thing Interaction Framework.

 Thing Interaction Framework


 Onboarding
 Sending Commands
 Receiving State Information
 Auto Execution with Triggers
 Tuning with the Kii Cloud SDK for Thing
 Gateway

This section provides only the overview. See Function Guide for the functional details
and Programming Guides for programming implementation.

Thing Interaction Framework


The most basic functionality of Thing Interaction Framework is to transfer commands and
state information.
The mobile app user remotely controls the managed thing via the Internet by
sending commands to the thing. In the opposite direction, the mobile app user can browse
the internal state of the thing such as sensor values and settings as state information.

Develop the mobile app and the thing program according to the specification of your IoT
solution. Incorporate the Thing-IF SDK into the mobile app and the thing program and set
them to access the same application on Kii Cloud.

Onboarding
Thing Interaction Framework has the concept of a thing owner. Onboarding associates a
user with a thing. The user or group which became a thing owner can send commands and
receive state information.
The mobile app user logs in with the API of the Kii Cloud SDK and onboards the thing by
specifying its vendorThingID (There are different onboarding methods available).
vendorThingID is an ID that the developer can freely assign to a thing. When a thing is
registered to Kii Cloud, thingID is assigned to it. After that, you can use either
vendorThingID or thingID to reference the registered thing.
In the example below, User A and Thing 1111 , and User B and Thing 2222 are
onboarded, respectively.
The thing can receive commands from and send state information to its owner. If any non-
owner user attempts to access a thing, Thing Interaction Framework issues a security error.

Sending Commands
Once the onboarding completes, the mobile app can send commands to the thing to remotely
operate it via the Internet.
The details of the remote operation is represented in JSON format.
The below figure shows the operation flow.
The user action on the mobile app sends a command to Thing Interaction Framework which
transfers it to the target thing ( ). The thing parses the command and controls the hardware
( ). The thing returns the execution result as the command result and Thing Interaction
Framework notifies the mobile app of the command completion ( ). Note that
process actually involves two steps: receiving the command completion and getting the
command result.

The command consists of multiple actions represented as parameters in JSON format. You
can freely define the number of actions and their parameters according to the specification of
your IoT solution.
The below figure shows an example with an air conditioner. The command contains
the turnPower action for the power supply operation and the setPresetTemperature action
for specifying the preset temperature.
After the command is executed, you can get the command result which includes the
success/failure and error messages.
Receiving State Information
The mobile app can receive state information registered by the thing. State information
indicates what the thing is like, such as its sensor values and results of actions taken by
commands from the mobile app.
As with actions, you can freely define the contents of state information in JSON format
according to the specification of your IoT solution.
The below figure shows the operation flow.
The thing registers state information to Thing Interaction Framework at the interval set by the
Thing-IF SDK ( ). The operation of the mobile app such as user actions gets and uses the
state information ( ).

Auto Execution with Triggers


By using the trigger feature, you can automatically execute a command or server code when a
predefined execution condition is met. The server code feature is described in Server
Extension in the section of the mobile features.
You can automatically execute a command and server code with the following conditions:
 When a scheduled time arrives
You can automatically execute a command when a scheduled time arrives. Specify a
one-time or recurring schedule.
For example, you can register a trigger to send a command to turn off the air
conditioner "at 11:00 p.m. from Monday to Friday".
 When a state condition is met
You can automatically execute a command or server code when a state of the thing
satisfies the condition to fire the trigger.
For example, you can register a trigger to send a command to turn on the air
conditioner with the preset temperature and fan speed set to 25 degrees and 5,
respectively, "when the room temperature goes over 30 degrees".

Tuning with the Kii Cloud SDK for


Thing
You can tune the functionality of Thing Interaction Framework with the Kii Cloud SDK for
Thing if Thing Interaction Framework does not satisfy your requirements for the service to be
developed.
The Kii Cloud SDK for Thing includes enhancements for things as well as the features
described in Mobile Features. The following features are available in addition to the mobile
features.

Thing Management
You can manage things on Kii Cloud. You can register things to Kii Cloud and specify users
and/or groups which can access those things as an owner.
The below figure shows an example of thing management with smart LED lights. Users and
groups can become an owner of things. If a group is an owner, all the group members can
access the owned thing.
Thing Scope
You can use the thing scope if you use the Kii Cloud SDK for your IoT solution. This scope
is comparable to the scopes described in Scopes and Access Privileges for mobile apps.

Each thing has its own scope. The thing scope is suitable for handling thing-specific data,
such as data detected by each thing as objects. You can manage buckets per thing like the
other scopes.
The thing owner (users and/or groups) can access data in the thing scope. However, the thing
cannot access its owner's data by default. To allow the thing to do so, you need to change the
ACL.

Application Example

The current version of Thing Interaction Framework does not support a scenario where the
thing should notify the mobile app of an abnormal sensor value detected on the thing.
You can provide this feature through the push notification feature of the Kii Cloud SDK.
Create a topic in the thing scope and have the owner subscribe to it. You can notify the owner
of an abnormality on the thing by sending a message to the topic.

Gateway
Kii Cloud supports connection via the gateway. This feature enables to connect various
devices to Thing Interaction Framework via an IoT gateway product.
Some things only support lightweight protocols such as Bluetooth and Zigbee and cannot
directly connect to the Internet. You can connect such things to the gateway as end
nodes and have the gateway convert protocols. This enables the things to use the functions of
Thing Interaction Framework.

When the gateway is installed, Thing Interaction Framework manages connection relations
between the gateway and end nodes as shown below. Requests are delivered to specific end
nodes via the gateway connected to those end nodes.
You can scale the number of end nodes and support flexible operation because the gateway
feature includes processes of routing to end nodes and replacing broken devices.

If you want to treat the IoT gateway and end nodes as one unit, you can configure the
gateway device as a standalone thing and leave the gateway feature of Kii Cloud unused. In
this case, Kii Cloud recognizes the gateway and end nodes as one thing. You need to
implement processes such as command routing to end nodes in your thing program. Consider
this simple configuration for a simple deployment where the number and types of end nodes
are limited and changes in the configuration are minimum.

Next Step
Now that you have read the overview, Kii recommends reading the code of Hello Thing-IF, a
set of sample IoT programs.

Hello Thing-IF is designed to walk through implementation steps of both the mobile app and
the thing program, which operate a simulated smart LED light. Use this sample as a reference
if you develop IoT solutions with Thing Interaction Framework.
See Hello Thing-IF for more information about the sample code.
Function Guide
The Function Guide explains Kii Cloud functions and mechanism.
The guide explains the functions basically without program code.
The content of the guide is as follows:
 Kii Cloud Structure
This section explains the detailed specifications of the SDKs and applications which
are part of Kii Cloud. This section applies to both mobile apps and IoT solutions.
 Kii Cloud SDK
This section explains the Kii Cloud functions used to develop mobile apps. Read this
section to outline the various functions including user management, data management,
and push notification. You can also find the detailed functional specification in this
section.
The target reader is those who are considering about using the Kii Cloud. If you are a
developer, we recommend you to start from Kii Cloud SDK Programming Guides.
 Thing-IF SDK
This section explains the Kii Cloud functions of the Thing-IF SDK used to develop
IoT solutions. The section also explains how to tune the functions with the Kii Cloud
SDK in the IoT environment.
For the better implementation, we recommend you to understand the functional specification
first and then check the program codes in the Programming Guides.

Kii Cloud Structure


Kii Cloud provides a dedicated SDK for each mobile platform and each function.
This section introduces the structure of Kii Cloud and SDKs.

SDKs and Supported Environments


Kii Cloud provides a dedicated SDK for each mobile platform and each function, as
illustrated below. In this section, we will summarize the supported environments for these
SDKs.
The basic data model and implementation method are the same for all client SDKs. This
makes it easy to develop your applications on multiple platforms; by mastering development
on one platform, migrating your application to other platforms should be fairly smooth.

For Mobile Application Development


The following SDKs are available for developing mobile applications.
 Kii Cloud SDK for Android
This is a Java SDK that supports Android 2.3.3 (API level 10) and later. You will use
the SDK by integrating it into your application. You can download the SDK
automatically from the Maven repository.
 Kii Cloud SDK for iOS
This is an Objective-C/Swift SDK that supports iOS 8.0 and later. The SDK supports
development with Xcode 6 and later. You will use the SDK by integrating it into your
application. You can download the SDK automatically using CocoaPods.
 Kii Cloud SDK for JavaScript
This SDK supports the following environments:
o Web browser
The SDK supports the following browsers:

 Mozilla Firefox 14 and later.


 Google Chrome 20 and later.
 Safari 5 and later.

We confirmed that the basic SDK features also work on Internet Explorer 11
and Microsoft Edge, but not guaranteed.
Please use the SDK by downloading it and by integrating the JS file into your
application.
o Apache Cordova
Please use the SDK by downloading it and by integrating it into the Cordova
configuration file.
o Node.js
You can use the SDK on the environment in which Node.js v0.10.0 or later
runs. You can install the SDK package with the npm command
and package.json and then load the SDK module into your app.

o Server Extension
You can use the SDK for writing your server code. No preparation is needed
when writing your server code.
 REST API
The REST API allows you to directly access Kii Cloud features via a HTTPS
connection. When using the REST API, you will pass the parameters as JSON.
You can use any HTTPS client provided by various programming language runtime
or third-party libraries to access Kii Cloud and to leverage the Kii Cloud features. The
client SDKs also internally communicate with HTTPS to execute the REST API. For
example, you can leverage Kii Cloud features on platforms that do not have dedicated
Kii client SDK (e.g., desktop PC) with the REST API. The REST API will also allow
you to execute the Kii Cloud API with Node.js from other servers.
Unlike other client SDKs, you do not need to download anything when you are using
our REST API.
 Command Line Tool
This command line tool provides the following two features:

o Server Extension Management: The tool lets you manage Server Extension
Feature. On Kii Cloud, you can write JavaScript code (server code) for putting
your custom logic on the server. The Server Extension Tool acts as a tool for
managing server code, like uploading them to Kii Cloud.
o Developer Log Browsing: The tool let you browse the server logs on Kii
Cloud.

Note that you will need Node.js v0.10.11 or later to use this tool.
 Developer Portal
This is a Web UI that provides various features for application developers and
administrator. You can configure your application on the developer portal. Also, you
can check the application analysis results.
You can also use the data browser and user console to check the data uploaded by
your application.
Currently, the following browsers are supported (Internet Explorer is not supported):

o Mozilla Firefox 14 and later.


o Google Chrome 20 and later.
o Safari 5 and later.

For IoT Application Development


The following SDKs are available for developing IoT solutions.
 Thing-IF SDK for Android
This is a Java SDK that supports Android 2.3.3 (API level 10) and later. You will use
the SDK by integrating it into your application. You also need to use the Kii Cloud
SDK (e.g., for managing users). You can download these SDKs automatically from
the Maven repository.
If you are not going to use the Thing-IF features, you can solely use Kii Cloud SDK.
 Thing-IF SDK for iOS
This is a Swift SDK that supports iOS 8.0 and later. The SDK supports development
with Swift 2.3 in Xcode 8.
The SDK and all of the sample code in the development guide are implemented and
tested in Swift.
Download the framework using CocoaPods and integrate it into your application. You
need to use the Kii Cloud SDK (e.g., for managing users).
If you are not going to use the Thing-IF features, you can solely use Kii Cloud SDK.
 Thing-IF SDK for JavaScript
This SDK is designed to develop client web apps for IoT solutions. You can use
TypeScript or JavaScript for web app implementation.
Web apps developed with this SDK require web browsers which support
ECMAScript 5 and promises in the global namespace. Kii has verified that the SDK
supports Mozilla FireFox 49, Google Chrome 53, Safari 9, and Microsoft Edge 38.
You will use the SDK by integrating it into your application. You also need to use the
Kii Cloud SDK (e.g., for managing users). You can download these SDKs from the
developer portal, GitHub, or the npm repository.
Node.js v0.10.0 or later is required to build the SDK or web app. Build them with
the npm command.

This SDK does not support implementation on the thing side. You cannot use this
SDK with server code.
 Kii Cloud SDK for JavaScript
This SDK can be used in both mobile apps and IoT devices.
See the description in the For Mobile Application Development section if you use this
SDK on the mobile app side.
You can use this SDK in the environment which runs Node.js v0.10.0 or later. After
installing Node.js on the thing, run the npm command to install the SDK package and
load the SDK module to use it.
 Thing-IF SDK for C
This is a C SDK designed to be embedded in IoT devices. We provide a reference
implementation for embedded Linux. You need to download the SDK's source code
and integrate it into your device.
You can solely use the Thing-IF SDK for C. You can also use it together with the Kii
Cloud SDK for Thing.
 Kii Cloud SDK for Thing
This SDK is to be embedded in IoT devices (things). This SDK uses the Kii Cloud
features directly and does not use the Thing-IF platform.
The SDK is for the implementation in C language on an embedded Linux. To use this
SDK, you will download the SDK and integrate it into your device.
 Gateway Agent
A gateway provides the Internet connection to devices (end nodes) that have no
capability to connect to the Internet directly. The gateway agent is a set of built binary
files and runs as a resident process on the gateway for controlling it.
 Converter
To connect the gateway and end node, you also need to develop a converter for
translating the protocols. We provide a reference implementation with the source
code, and you can use it as a skeleton for developing your converter quickly.
 REST API
You can use the REST API directly from both a mobile and thing environment.
In a mobile environment, you can leverage IoT-related features, such as the thing
management feature, in addition to the features for developing a mobile app. In a
thing environment, you can leverage features such as the data and thing management
features from the thing side.
For the features provided by the Thing Interaction Framework, you can use the
MQTT instead of using the HTTPS; you can execute the same API with the MQTT.
These are the same as those for the mobile app development. Please read the description in
the previous section.

 Kii Cloud SDK for Android


 Kii Cloud SDK for iOS
 Command Line Tool
 Developer Portal

Client SDKs
The following SDKs are available for developing mobile applications and IoT solutions. You
can also call the REST API directly with any HTTPS client to leverage the Kii Cloud features
without using the SDK.
For Mobile Application Development
The following SDKs are available for developing mobile applications.

Android iOS JavaScript REST

Kii Cloud SDK Yes Yes Yes Yes

Kii PhotoColle SDK Yes Yes - -

 Kii Cloud SDK


Kii Cloud SDK provides the basic features, like data management user/group
management, and application analytics. The SDK also provides the push notification
support.
The features previously provided by the Kii Analytics SDK are now integrated into
the Kii Cloud SDK.
 Kii PhotoColle SDK
This SDK provides the integration with d ACCOUNT and "d PHOTO" service
provided by NTT docomo.
This SDK is required when you are going to provide user authentication with d
ACCOUNT and integration with the d PHOTO service. Note that this feature is only
available when you select "Japan" as the server location.
There are also many libraries (e.g., Python2, Go, and PHP libraries) provided by our
contributors. Please check Samples and Tutorials for more information.

For IoT Application Development


You can connect things in two ways. You can connect them directly as standalone devices, or
you can connect them indirectly via a gateway.
The available SDKs differ for these two scenarios.

Connecting Directly as Standalone Devices


If you are going to connect things directly to Kii Cloud and Thing Interaction Framework, the
following SDKs are available for implementing your mobile application and things. By
implementing both the mobile applications and things, you can realize the integrated IoT
services.

Using
Development
Environment/Language Thing-IF Kii Cloud both
Target
*1
Thing-IF SDK Kii Cloud SDK
Android OK
for Android for Android*2

Thing-IF SDK Kii Cloud SDK


iOS OK
for iOS for iOS *2
Mobile
Application Kii Cloud SDK
Thing-IF SDK
JavaSciprt for OK
for JavaScript
JavaScript *2

REST API REST API (Kii


REST API OK
(Thing-IF SDK) Cloud SDK)*2

Thing-IF SDK Thing SDK


C OK
for C Embedded

Kii Cloud SDK


JavaScript *3 - for -
JavaScript *2
Thing
REST API
(Thing-IF
SDK) / REST API (Kii
REST API OK
Executing APIs Cloud SDK)*2
via the MQTT
protocol

*1 If you want to leverage both SDKs, develop your program with the implementation
procedures of the Thing-IF SDK first. Then, leverage the Kii Cloud SDK features.
*2 The features are integrated into the SDK for the mobile application development. The
linked pages cover only the IoT-related features, but you can also leverage all features for
developing mobile applications as well.
*3 Install Node.jS on the thing and run your program on the thing with Node.js.

Connecting Indirectly via Gateway


When you are connecting things via a gateway, you can only use the features of the Thing
Interaction Framework from the things and from the mobile application.
You can realize the integrated IoT services by implementing the mobile application and
converters and by configuring the gateway.
If you want to use the features of the Kii Cloud, you need to use some tricks, like executing
the Kii Cloud REST API directly from the converter.

Development Target Environment/Language Thing-IF


Android Kii Cloud SDK for Android *1

Mobile Application iOS Kii Cloud SDK for iOS *1

JavaSciprt -

Thing
Go Reference implementation available
(Converter)

*1 You also need to use the Kii Cloud SDK for managing users. You can use all SDK
features on the mobile application side, but there is no direct support on the thing side.

Available Features
The following table summarizes the features currently supported by each client SDK and
REST API.

For mobile application development


The following features are supported for developing mobile applications.

REST
Feature Android iOS JavaScript
API

Kii Cloud SDK

Registering,
authenticating and Yes Yes Yes Yes
deleting users

Registering with an
Yes Yes Yes Yes
email/phone number

Saving user attributes Yes Yes Yes Yes


User
management Using refresh tokens,
logging in with the Yes Yes - Yes
auto-saved credentials

Integrating with
Details Details Details Details
external services

Changing and resetting


Yes Yes Yes Yes
passwords

Group Creating and deleting


Yes Yes Yes Yes
management groups
Changing a group
- - - Yes
owner

Managing group
Yes Yes Yes Yes
members

Creating and deleting


Yes Yes Yes Yes
buckets

Saving KiiObjects (key-


Yes Yes Yes Yes
value pairs)

Putting Geolocation in
Yes Yes Yes Yes
KiiObjects
Data
management Leveraging object
Details Details Details Details
bodies (files)

Putting access controls


Yes Yes Yes Yes
on buckets/KiiObjects

Accessing data as an
application - - Yes Yes
administrator

Operation with the


administrator - - Yes Yes
privileges
Admin feature
Application
configuration, force
- - - Yes
password reset,
disabling users

A/B testing Yes Yes - Yes

Configuring and
Yes Yes Yes Yes
subscribing push
Push
Sending push messages Yes Yes Yes Yes
notifications
Receiving push
Yes Yes Yes -
messages *1

Server Executing server code


Yes Yes Yes Yes
extension manually
(Executing
server code) Coding server code & - - Yes -
executing server code
with triggers and by
schedule

Checking basic
Yes Yes Yes Yes
analytics

Defining and checking


Application custom analytics Yes Yes Yes Yes
analytics (application data)

Defining and checking


custom analytics (event Yes Yes Yes Yes
data)

Kii PhotoColle SDK (only available with "Japan" server location)

Integrating with NTT d ACCOUNT and d


Yes Yes - -
PHOTO service

*1 For the technologies available for receiving push notifications, see Push
notification below.

Push notification
You can use different push notification technologies with Kii Cloud depending on the target
SDKs and platforms. See the below table for available technologies.

Platform Push Notification Technology

Android FCM or JPush

iOS APNs

For Android FCM

Cordova For iOS APNs

JavaScript For the others -

Browser MQTT over WebSocket

Node.js MQTT over the TCP socket

Note these considerations:


 JPush works with various platforms. Currently, only the Kii Cloud SDK for Android
supports JPush for receiving push notifications.
 With the Cordova, the available push notification technology is different depending
on the target platform of your mobile app.
 Normally, use WebSocket with MQTT because a number of JavaScript libraries
assume use of WebSocket with MQTT. However, the Kii Cloud API supports direct
use of TCP in MQTT communication.

For IoT application development


The features available for developing IoT applications are different between the Thing-IF
SDK and the Kii Cloud SDK.

Thing-IF SDK

Both mobile apps and things can make use of all the features supported by the Thing-IF SDK.
 Mobile app side
The Thing-IF SDKs for Android, iOS, and JavaScript allow you to implement IoT
functions in your mobile app. You can make use of the features for mobile apps in
Thing Interaction Framework, such as sending commands, getting the state, and
setting automatic execution.
Basically, the same features are available across the platforms except that the SDK for
JavaScript supports a different set of features.

Feature Android iOS JavaScript

Using Thing Interaction Framework Yes Yes Yes

Locally saving and restoring initialized ThingIFAPI


Yes Yes -
instances

Operating with non-owner's privilege such as an


- - Yes
app administrator's

Operating gateways Yes Yes -

 Thing side
The Thing-IF SDK for C allows you to implement IoT functions in your thing. You
can make use of the features for things in Thing Interaction Framework, such as
receiving commands and registering the state.

Kii Cloud SDK

 Mobile app side


You can make use of the features below in addition to the all the features for mobile
apps when you develop your mobile app for an IoT solution.
REST
Feature Android iOS JavaScript
API

Registering things,
setting owners,
Yes Yes Yes Yes
managing data in the
thing scope

Thing Authenticating with


management PIN code and - - - Yes
checking owner

Manipulating with an
access token of a - - Yes *1 Yes
thing

*1 In general, mobile apps do not use the thing access token. This feature is used in
thing implementation.
 Thing side
You can select the environment to add the SDK for things from the C language or
JavaScript (Node.js). You can also use the REST API.
If you use the C language, you can make use of the features of Kii Cloud through the
Thing SDK Embedded which is internally used in the Thing-IF SDK. The APIs of the
Thing SDK Embedded allow you to make use of a subset of features required for
thing implementation. You can make use of all the features of Kii Cloud through the
API call function in the Thing SDK Embedded.
If you use JavaScript, you can make use of all the features of the Kii Cloud SDK for
JavaScript on Node.js. Access to Kii Cloud is achieved with the thing access token.
Note that the Thing-IF SDK for JavaScript does not support implementation on the
thing side.

Push notification
The technologies available for mobile application development can be used with mobile apps
for IoT solutions. See Push notification in the section above for mobile application
development.
Usually, MQTT is used on the thing side.

SDK installation
Please read the following sections to learn how to install the client SDKs.

For Mobile Application Development


Android

 Read Android Quick Start to learn how to use the client SDK.
 Read Server Extension Programming Guide to learn how to leverage the Server Extension.

iOS

 Read iOS Quick Start to learn how to use the client SDK.
 Read Server Extension Programming Guide to learn how to leverage the Server Extension.

JavaScript

 Read JavaScript Quick Start to learn how to use the client SDK.
 Read Server Extension Programming Guide to learn how to leverage the Server
Extension.

REST

 No download module needed. You just use any HTTPS client to call Kii Cloud REST API.
 Read Server Extension Programming Guide to learn how to leverage the Server Extension.

For IoT Application Development


Android

 Read Android Application Development Guide to learn how to use Thing Interaction
Framework with the client SDK.
 Read Server Extension Programming Guide to learn how to leverage the Server Extension.

iOS

 Read iOS Application Development Guide to learn how to use Thing Interaction Framework
with the client SDK.
 Read Server Extension Programming Guide to learn how to leverage the Server Extension.

JavaScript

 Read JavaScript Application Development Guide to learn how to use Thing Interaction
Framework with the client SDK.
 Read Server Extension Programming Guide to learn how to leverage the Server Extension.

Thing

 Read Thing Development Guide to learn how to use Thing Interaction Framework with the
client SDK.
 Read Server Extension Programming Guide to learn how to leverage the Server Extension.
Network Environment
Kii Cloud and clients communicate over a network. The client SDK uses the HTTPS protocol
to access the Kii Cloud REST API. To support the push notification feature, devices, things,
and servers for the push notification services communicate over the network. Web apps and
things use the MQTT protocol over the TCP socket or WebSocket to use push notification
and the API.
You particularly do not need to care about the TCP port if devices are on the public network.
If the devices are on a private network such as a corporate intranet, make sure that the
following TCP ports are open:

Mobile Apps
The following ports are used for mobile communication:

 Accessing the Kii Cloud API


o HTTPS: Outbound port 443
 Push notification
o FCM (Android): Outbound port 5228, 5229, 5230. GCM uses the same ports. More
information.
o APNs (iOS): Outbound port 5223, 2195, 2196, 443. More information
o JPush (Android): Outbound port 19000, 3000-3020, 7000-7020, 8000-8020. More
information
o MQTT (JavaScript): Outbound port 12473 (over WebSocket with SSL/TSL)

The client SDKs are designed to use HTTPS for API call and respective ports for the push
notification service in use.

IoT
See the sections below for the ports used by the mobile side and the thing side.

Mobile Side
See Mobile Apps for the ports used by the mobile side.

Thing Side
Select one from the two communication methods below for communication between Kii
Cloud and things.

HTTPS for API Call and MQTT for Push Notification

This method uses HTTPS for sending requests to Kii Cloud as with mobile apps, and
MQTTT over the TCP socket with SSL/TSL for push notification. Any SDK for things uses
this method. See For IoT Application Development for available SDKs for things.
The following ports are used:

 Accessing the Kii Cloud API


o HTTPS: Outbound port 443
 Push notification
o MQTT: Outbound port 8883 (over the TCP socket with SSL/TSL)

MQTT for Both API Call and Push Notification

This method uses only MQTT in implementing the thing. You do not need to prepare for
HTTPS. However, you need to call APIs directly because no SDK supports this method.
See Using API via MQTT to learn how to implement the communication function only with
MQTT.
The following port is used:

 MQTT: Outbound port 8883 (over the TCP socket with SSL/TSL)

MQTT Protocol
MQTT is a lightweight and bidirectional protocol which is often used in the IoT (Internet of
Things) area. In Kii Cloud, you can leverage the following features with the MQTT.

 Using Push Notification with Web App


 Using Thing-IF SDK/Thing SDK Embedded
 Using Push Notification on Node.js
 Using MQTT Only with Thing Client

See MQTT Protocol in the Thing-IF SDK guides for more information on the mqtt protocol.
Kii Cloud Application
The first thing you will do after you are done with Kii Cloud registration is to create an
application on Kii Cloud. This section explains how the created application is treated on Kii
Cloud.

Application
To start leveraging Kii Cloud, you first need to create your application on the developer
portal. This will allocate the necessary region for your application and service on Kii Cloud.
You can use the application both from the Kii Cloud SDK and from the Thing-IF SDK.
All data stored in Kii Cloud are segregated per application. Suppose, for example, that
Developer A creates "PhotoAlbum" and "CarRacing" applications and Developer B creates
"CarRacing" application on Kii Cloud.

 Kii Cloud will treat all of these applications independently. The "CarRacing"
applications made by Developer A and B are treated separately although their names
are identical.
 Kii Cloud allows multiple SDKs to access the same application. For example,
Developer A can create his "PhotoAlbum" application for both Android and iOS, and
they can share the same data (e.g. sharing photos uploaded by an Android application
with an iOS application).

Creating applications
When creating an application, you will specify the following information:
 Application Name
The application name is used for identifying your application on the developer portal.
The client SDK does not use the application name for identifying the application;
instead, it will use the AppID (ref. Access Keys). Multiple applications having the
same application name is perfectly ok.
 Server Location
Specify the server on which you want to create your application. Kii Cloud servers are
currently located in the United States, Japan, China, Singapore, and Europe.
See Selecting the server for more details.
 Client SDKs
Specify the client SDKs you are going to use for the development. The REST API is
always available. You can later change this setting, so you can start by selecting the
minimum set.
If you are not going to use any SDK in the selection (e.g., You are going to use Kii
Cloud SDK for Thing or REST API), select any SDK here to create your application.

Selecting the server


You need to select the server location when you create a new application. The available
server locations are the United States, Japan, China, Singapore, and Europe.
An application uses one fixed server location. When you implement the application, you will
specify the server location in a parameter passed to the initialization API.
Each application is independent. Two applications do not share the data even if they have the
same name. You cannot change the server location after you create it.

Selecting the server location

We advise you to select the nearest server location from where your application will be used.
The "nearest" here means both physically and network-topologically.
One useful tip for finding the nearest server location in network-wise is to check the response
time by executing the following command. You can execute the command several times to
calculate the average response time and determine the best server location.
time curl -v -X GET "https://api.kii.com/"
Please change the access URL to change the server location to check.

 United States: https://api.kii.com/


 Japan: https://api-jp.kii.com/
 China: https://api-cn3.kii.com/
 Singapore: https://api-sg.kii.com/
 Europe: https://api-eu.kii.com/

You will get a "404 Not Found" HTTP response by executing the command, but you will also
get the time the response time to the server.
The client SDKs and REST API also access to the above URLs. If you encounter a network
error on your device, you can use the above command to check if the target server is down or
not.

Available features on each server location

Although all basic Kii Cloud features are available on all of the server locations, some
features are not available on certain server locations.
Please check the table below for the available features on each server locations.

US Japan China Singapore Europe

Push notification with FCM Yes Yes Yes Yes

Integration with Facebook, Twitter,


Yes Yes Yes Yes
Google, and Dropbox

Integration with d ACCOUNT and


Yes
PhotoColle SDK

Other features Yes Yes Yes Yes Yes

Access Keys
When you create an application, Kii Cloud will assign the following four access keys to it:
 AppID and AppKey
The AppID is used by Kii Cloud to identify your application. Kii Cloud will
determine which application is calling API with this key. The key is to be embedded
in your mobile app or JavaScript code.
The AppKey is not used by Kii Cloud anymore; the AppID solely determines the
application. When calling API, you can set an arbitrary value as the AppKey. You
can, of course, use the value assigned by Kii Cloud as the AppKey.
 ClientID and ClientSecret
These two keys are needed when you are accessing APIs that require the application
administrator privileges.
These keys are equivalent to the administrator password; once a user provides these
keys, he will gain the full access to your application, like changing any user's
password and modifying any application data.
The keys, therefore, must be securely handled. Never embed them in your
applications (native applications or JavaScript) that are to be distributed to the public.
See "Security" (Android, iOS, JavaScript, REST) for more information.

Collaborators
You can manage your application with other developers (collaborators).
Just after you create a new application, you are the only developer who can manage it on the
developer portal. But you can specify other developers as collaborators to jointly manage
your application. The collaborators will have almost the same privileges as you, except for
adding more collaborators and so on.
You can invite other developers as collaborators by entering their email addresses on the
developer portal. Kii Cloud will send invitation emails to them. Existing Kii developer
account owners can become a collaborator. They will see applications which they are
involved as a collaborator as well as their own applications in the developer portal.
Kii Cloud SDK
Kii Cloud SDK provides the basic functions for leveraging Kii Cloud. In this section, we will
explore the features covered by this SDK.
In this section, we will partially explain the features provided by Kii Cloud SDK for Thing.
See Tuning with Kii Cloud SDK for Thing for the full explanation on the Kii Cloud SDK for
Thing.

User Management
Kii Cloud SDK provides features to manage your application users, such as sign-up and
login.
With the user management features of Kii Cloud, you can not only manage the membership
of a mobile app but also store data per user (data in the user scope) with appropriate security
and identify recipients of push notifications.
The user management is necessary for almost all mobile apps, including those that do not
have an explicit login screen.

Creating a User
A Kii Cloud user (a KiiUser object) represents an end user of a mobile app.

A user manipulates various data in a mobile app on their device such as a smartphone. It is
appropriate to save most of such data in association with the user, not the device (though such
data can be saved in a different bucket per device).
If you use the Thing SDK for your IoT solution, a thing becomes available by associating it
with a user who is the thing owner.

The following three methods are available to identify the users registered to Kii Cloud.
 Authenticating with the username and the password
A user signs up with a username and a password and logs in with those credentials.
You can request an email address and/or a phone number instead of a username, or a
combination of them.
 Using a pseudo user
The pseudo user feature allows end users to access Kii Cloud without explicit login.
When the API to create a pseudo user is called, Kii Cloud creates a user account and
issues an access token for the user account. By keeping the access token on a mobile
app, the end user can access the user account on Kii Cloud. Pseudo user accounts
cannot be logged in.
If the end user needs to change their device, you can let them log in from a new
device. To do so, have the end user register a username and a password or link the
pseudo user with an external service account.
 Authenticating with an external service account
Kii Cloud can identify end users with account information of various web services
including Facebook and Twitter instead of credentials specific to Kii Cloud. Identified
accounts of such web services can be used as Kii Cloud user accounts. External
services perform authentication based on OAuth.
For providing services in China, some of the Kii Cloud SDKs support authentication
with accounts of Renren (人人網), Sina Weibo (新浪微博), and QQ.

These identification options of Kii Cloud reduce barriers for end users to sign up for your
mobile app.
Especially, using pseudo users or external service accounts would be effective for end users
who want to avoid user registration for every mobile app.

Learn more...

 For more information about user registration and pseudo users, see "Registering and
Logging in a User" (Android, iOS, JavaScript, REST).
 For more information about authenticating with an external service account and the
supported external services per platform, see "Authenticating with an External Service
Account" (Android, iOS, JavaScript, REST).

Logging in and Using an Access


Token
When a registered user is authenticated, Kii Cloud issues an access token. An access token is
issued also for a pseudo user when it is created.
An access token is always sent to Kii Cloud when an API is called while a user is logged in.
As a result, Kii Cloud can identify the API caller.
Using an access token
Your mobile app accesses Kii Cloud via the Kii Cloud SDK. Requests are sent from the SDK
to Kii Cloud according to the API specification published as REST APIs.

When a user logs in with their username and password, Kii Cloud issues an access token that
allows operations permitted for the user.
The issued access token is specified in the HTTPS header of the subsequent REST API
requests. This identifies the requester and allows operations permitted for the user.

The above figure illustrates a process flow where a user logs in and calls two APIs.
1. The user logs in with the user ID aaaa and password bbbb and receives the access
token 9nM5Nzu-NXLle in the response. An actual token is longer than this sample
token.
2. When a function is executed with the privilege of the user aaaa , an API is called with
the access token 9nM5Nzu-NXLle specified.

3. The other function is executed in the same way.


The Kii Cloud SDK transparently handles an access token. The SDK identifies the logged-in
user as the current user.
All the functions supported by the Kii Cloud SDK are published as REST APIs. In general,
almost all of the functions are avaiable via the Kii Cloud SDK, but you can also get an access
token and directly call REST APIs.
Saving and restoring login information
In order to keep a user logged in on a mobile app, the Kii Cloud SDK provides the following
two methods to save an access token.
 The login state can be restored by reusing an access token that was obtained from the
Kii Cloud SDK at the previous login.
 User information including an access token is automatically saved to the shared
preferences or the keychain when the Kii Cloud SDK executes a function such as
login. The login state can be restored when a mobile app is restarted by using the
saved user information.

Security features
In connection with the login processing, the following security features are available.

 The expiration time of an access token can be configured with an API or in the developer
portal. The administrator can also forcibly disable an access token by disabling a user in the
developer portal.
 The user can update and reset their password with an API. The administrator can reset the
user's password in the developer portal.
 Kii Cloud supports the refresh token of OAuth 2.0. An access token can be regularly
refreshed.

Learn more...

 For more information about access tokens, logging in with an access token, and security, see
"Logging in and Using an Access Token" (Android, iOS, JavaScript, REST).
 For the REST APIs, see REST Programming Guide. For the detailed specification of each API,
see References.

Verifying the User's Email Address


and Phone Number
If your mobile app uses an email address and/or phone number for authenticating a user, you
can verify if the registered email address and/or phone number are valid by sending an email
or SMS message.
The administrator can enable the verification of email addresses and/or phone numbers in the
developer portal.
If the verification is enabled, the following processing is applied when a user is registered and
when the registered email address or phone number is changed.
 If the email verification is enabled, Kii Cloud sends a verification email to the specified email
address. The email address remains disabled until the user clicks the link in the verification
email.
 If the phone number verification is enabled, Kii Cloud sends a verification SMS message to
the specified phone number. The phone number remains disabled until the user sends the
verification code in the SMS message to Kii Cloud via the Kii Cloud API.

See the flow of the email verification below. The same applies to the phone number
verification.

You can add the verification process to your mobile app just by enabling the feature in the
developer portal. If you add the phone number verification, you need to develop a screen to
enter the verification code.
You can seamlessly incorporate the verification feature to your mobile app because the
feature allows you to customize the message content and switch the message language for
each user.

Learn more...

 For more information about the verification feature, see "Verifying the User's Email Address
and Phone Number" (Android, iOS, JavaScript, REST).

User Attributes
You can use user attributes to store various user data on Kii Cloud.
User attributes consist of predefined fields that have been defined by Kii Cloud and custom
fields that can be used for various purposes from your mobile app.
Both of predefined fields and custom fields can be referenced and updated via the Kii Cloud
SDK and the REST APIs.

Learn more...

 For more information about user attributes, see "User Attributes"


(Android, iOS, JavaScript, REST).

Group Management
You can manage groups of users with the Kii Cloud SDK. You can express relationships
among users that are registered in your application and let those users share information.
You can easily enable data sharing with the group feature. This feature is helpful when you
develop a mobile app that provides spaces where only members of certain groups can read
and write, for example, an SNS forum app, a bulletin board app, and a chat app. The group
feature can be used for defining relationships among users and saving group data in a bucket
in the group scope.
The group feature can be used also to define an administrative user who can access a limited
range of data.
By controlling access rights with the group feature, you can express user roles defined in your
own service specification.
When the number of users with such a role changes, you can thoroughly change the access
rights to the target resource by centrally configure the access rights through a group.

Learn more...

 For more information about the use of groups and the purposes of group management, see
"Managing Groups" (Android, iOS, JavaScript, REST) in the programming guides.
Managing Group Members
A user (KiiUser) can be associated with a group (KiiGroup) by two types of relationship in
Kii Cloud: member relationship and owner relationship.
 Owner
Any logged-in user can create a group in the Kii Cloud application. The user who
creates a group will become the owner of the group.
 Member
A group can have multiple members who can access buckets in the group scope and
the resources that the group members are allowed to access by the resource ACL.
The group owner is also the first member of the group.
An owner and a member are expressed as two-way relationships between a KiiUser and a
KiiGroup on Kii Cloud. When any group-related actions are performed, for example, addition
or removal of a group member and deletion of a user, Kii Cloud automatically updates those
two-way relationships.
As indicated in the figure below, you can get relationships between a user and a group with
the methods of the KiiUser and KiiGroup classes of the Kii Cloud SDK. Each string such
as memberOfgroups() in the figure represents the method to get such a relationship.

Example of groups and users


See the figure below for relationships created through the following three actions as an
example of groups and users:
1. Alice creates the Sales Div. group. Relationships created from this action are
indicated by the red arrows.
2. Alice adds Bob to the Sales Div. group. Relationships created from this action are
indicated by the blue arrows.
3. Bob creates the Tennis Club group. Relationships created from this action are
indicated by the green arrows.
Learn more...

 For creating a group, see "Creating a Group" (Android, iOS, JavaScript, REST).
 For more information about the owner and member features and implementation methods
such as configuring members, see "Relationship between a User and a Group"
(Android, iOS, JavaScript, REST).

Group Access Control


In order to prevent unauthorized access against groups, such as adding a member to a group,
Kii Cloud provides group actions with predefined security settings.
As shown in the table below, logged-in users, group members, and group owners can perform
different sets of actions. For example, non-group members cannot access data in the group
scope and group members cannot remove any group member.

User not logged in User logged in

Non- Administrator
Group Group
Anonymous user group
member owner
member

Creating a
No Yes Yes
new group
User not logged in User logged in

Non- Administrator
Group Group
Anonymous user group
member owner
member

Referencing
an existing No Yes Yes Yes Yes
group

Accessing
data in the
No No Yes Yes Yes
group
scope *1

Adding and
removing
No No No Yes Yes
group
members

Changing
the group No No No Yes Yes
owner

*1 Subject to the ACL settings and the group actions.


If these security settings do not satisfy your service specification, you can customize the
access permissions. To do so, use the server codefeature to identify the user role defined in
the service specification and perform group actions with the administrative rights.
Kii Cloud ensures the security of your service with these access permissions.
These permissions are defined at the system level of Kii Cloud. Unless a user's access token
or password is leaked, no unauthorized access is possible even through a direct call to the
REST API.

Learn more...

 For more information about each group action and tips for customizing the access
permissions with the server code feature, see "Group Access Control"
(Android, iOS, JavaScript, REST) in the programming guides.

Data Management
Managing data is the fundamental feature of the storage SDK.
By uploading various data created on your application on Kii Cloud, you can store, share and
aggregate them in various manners.
The data can be in a form of key-value based JSON object or binary file. You can store both
of them as a set. These data can be freely handled so as to accommodate your application's
need without any customization on the server side.
This section covers the basics of the data management. If you want to jump directly into
some sample code, here are the links for you!

 Android guide
 iOS guide
 JavaScript guide
 REST API guide

Buckets and KiiObjects


In order to store data in Kii Cloud, you create buckets in one of the scopes and create
KiiObjects in the buckets.
For an overview of buckets and KiiObjects, see Mobile Features in the Getting Started guide.
Review this linked topic if you have not.

Bucket
As described in the Getting Started guide, you can create a bucket in any of the application
scope, group scopes, or user scopes. A bucket can be created also in a thing scope for your
IoT solution.
A bucket in the application scope is accessible to any user. A bucket in a user or group scope
is accessible to the user or group that owns the scope.
There are various advantages in using buckets. The purposes of using buckets are as follows:
 Organizing data
You can organize data as KiiObjects stored in buckets so that the data can be easily
managed by your service.
 Searching data
A search query is executed against a bucket for KiiObjects. You can execute a single
query and quickly retrieve KiiObjects that meet the search criteria by grouping
KiiObjects of the same type in a single bucket.
 Ensuring security
You can individually configure access rights of each bucket with its ACL. You can
easily customize the security setting by putting data for specific users and groups in a
bucket and configuring the bucket's ACL.

KiiObject
A KiiObject is a data structure that can hold a JSON document (key-value pairs) and an
object body (a file).
 JSON document (key-value pairs)
The Kii Cloud SDK provides functions that read and write key-value pairs in the
JSON document. The Kii Cloud SDK enables simple implementation with the
flexibility of JSON by accessing the JSON document with a method such as
the object.set(key, value) without any JSON parser.

You can represent nested data with a JSON document that has a hierarchy of multiple
levels by setting a JSON object as a value for a key.
The JSON format allows you to manipulate data on different OSes. You can easily
read data on an iOS device even if the data was written on an Android device.
 Object body
The object body feature allows you to attach large data such as a file to a KiiObject.
For a future overview, see Using Object Bodies.

Flexible design
You can create various data structures that serve the specification of your service by
optimizing the design of buckets and KiiObjects.
For example, suppose you need to save configuration data and messages for a chat service. It
is appropriate to store configuration data in buckets in each user's scope because such data
should be saved per user. On the other hand, messages should be stored in a bucket in each
group's scope because the group members share messages.
Besides, you can keep data private by storing it in a bucket in each user's scope, for example
in a health management app.

Access to buckets is scalable. User growth does not affect the performance unless you
encounter an issue such as a bottleneck caused because all the users access a single bucket.
All you need to do for creating a data structure is just saving data from the mobile app.
Your client implementation team can promptly build necessary features without server-side
implementation nor administrative configuration.

Learn more...

 For manipulating buckets and KiiObjects, see "Buckets" (Android, iOS, JavaScript, REST) and
"KiiObjects" (Android, iOS, JavaScript, REST) in the programming guide.
 You can create data structures such as a tree and a graph by representing relationships
among KiiObjects. For examples of data structures, see "Creating a Data Structure"
(Android, iOS, JavaScript, REST)

Querying and Retrieving KiiObjects


The following two methods are available to retrieve data from Kii Cloud:
 Retrieving a KiiObject by ID or URI
You can retrieve one KiiObject by specifying its ID or URI.
To retrieve a specific KiiObject, you need to save its ID or URI when the KiiObject is
created. You can choose to specify the ID of a KiiObject on your mobile app when
the KiiObject is created.
 Querying KiiObjects with conditions
You can retrieve a bunch of KiiObjects that meet a condition by querying a specific
bucket for KiiObjects.
You can also just count the number of KiiObjects that meet a condition without
retrieving the queried KiiObjects.

Querying KiiObjects
When a KiiObject is saved on Kii Cloud, the data at the first level of the JSON document
hierarchy are automatically indexed and become searchable. The data at the second and
subsequent levels are saved but not indexed nor searchable.
Indexes are automatically created when a KiiObject is saved. You do not need to define type
information in advance or take any actions to create indexes.
Even if a new query feature is added or the data format is changed after a service release, you
can still query data using the indexes without re-registration fo data.
You can create a query by combining conditions including the following with AND, OR, and
NOT clauses:

 Get KiiObjects that have a field value that satisfies a specified comparison condition (=, <,
≦, ≧, or >).
 Get KiiObjects that have a string field value that starts with a specified string.
 Get KiiObjects that have a field value that is equal to one of specified values.
 Get KiiObjects that have a field value whose type is equal to a specified type.
 Get KiiObjects that have a geolocation that is within a specified rectangular or circular area.

In addition to the values added by your mobile app, you can use these values in the JSON
document of a KiiObject for a query: the creation time and modification time of a KiiObject
and the ID of the user who owns a KiiObject.
When you retrieve KiiObjects, you can specify the maximum number of KiiObjects to be
retrieved at a time, the field for sorting query results, and the sort order of ascending or
descending.
For tips for optimizing the query performance, see "Performance"
(Android, iOS, JavaScript, REST).

Pagination

If a query returns many KiiObjects, you can use the pagination feature for dividing the query
results into multiple pages.
The client can retrieve all the query results by going through each page. Use features such as
page flip and unlimited scrolling in your mobile app for minimizing the time to display the
query results.

Learn more...

 For the specification of the JSON document to be queried, see "Accessing a JSON Document"
(Android, iOS, JavaScript, REST) in the programming guide.
 For more information about the query feature, see "Querying KiiObjects"
(Android, iOS, JavaScript, REST) in the programming guide.

Updating KiiObjects
When you determine how to update a KiiObject on Kii Cloud from the client, you can choose
from several methods according to your scenarios.
Kii Cloud accepts combinations of the following two options:

 Updating a KiiObject fully or partially


 Enabling or disabling the overwrite check
Updating a KiiObject fully or partially
You can choose how Kii Cloud updates existing key-value pairs in a JSON document on the
server with key-value pairs that are sent from the client.

 Full update: This method completely overwrites the data on the server with the data from
the client. Key-value pairs that are not included in the client request will be deleted from the
server.
 Partial update: This method merges the data on the server with that from the client and
overwrites the data on the server. Key-value pairs that are not included in the client request
will remain on the server.

The figure below shows how the two updating methods work. The data from the client does
not contain the gender key. The full update method deletes the key while the partial update
method keeps it.

Use these methods properly depending on the circumstances. The full update method is
appropriate for improving the communication performance because it sends only a subset of
large data. On the other hand, the partial update method helps to clarify what will remain on
the server after data is updated because it completely overwrites target data.

Enabling or disabling the overwrite check


With the overwrite check feature, you can use a technique known as optimistic locking and
ensure data consistency when multiple clients simultaneously update the same KiiObject.
You can also disable the overwrite check.
Suppose the overwrite check is enabled. When a client downloads a KiiObject from Kii
Cloud and then another client updates the KiiObject, a subsequent update from the first client
will be rejected.
The figure below shows how the overwrite check works. Client 1 and Client 2 download and
update the same KiiObject almost simultaneously. The update request from Client 2 is
rejected because Client 1 has updated the KiiObject.

If an error is returned, the mobile app needs to download and update target data again. It
might be more appropriate for some services to send a notification about a conflict.
You can prevent unexpected conflicts by enabling the overwrite check for buckets in the
application scope and group scopes because multiple clients are likely to write to such
buckets.
You can simplify the update process by disabling the overwrite check for buckets that are not
likely to have update conflicts, for example, in user scopes.
By utilizing optimistic locking, Kii Cloud ensures data consistency as well as scalability and
performance in the data updating process. User growth does not affect the performance
because Kii Cloud does not use exclusive locking.

Learn more...

 For more information about updating KiiObjects and optimistic locking, see "Updating a
KiiObject" (Android, iOS, JavaScript, REST) in the programming guide.
 The tutorial with a sample app Kii Balance includes tips for designing updating processes in a
real mobile app. See Data Consistencywhen you work on data design.
Using Object Bodies
A KiiObject can hold a JSON document and an object body. The object body feature allows
you to attach large data such as a file to a KiiObject.
You can perform the following tasks:

 Uploading and downloading an object body


 Publishing an object body

Uploading and downloading an object body


You can upload and download an object body on the client.
You can use either of the following methods for the object body transfer:
 Transfer-at-once
Transfer-at-once is a simple transfer method that uploads or downloads an entire file
in one request.
All the Kii client platforms support this method.
 Resumable transfer
With the resumable transfer, you can resume a transfer at the point of interruption
caused by a network outage or a user operation. This method is appropriate when you
need to transfer large files or users are in locations with low network quality.
The Kii Cloud SDKs for Android and iOS support this feature. The Kii Cloud SDK
for iOS additionally supports the Background Transfer feature of iOS.

Publishing an object body


You can publish and an object body so that end users can access it with a web browser.
When you call the API to publish an object body, Kii Cloud issues a URL. End users enter
the URL in a web browser and view or download the object body according to the content
type set to the object body.
Learn more...

 For more information about manipulating an object body, see "Accessing an Object Body"
(Android, iOS, JavaScript, REST) in the programming guide.

Using Geolocations
You can store and manage geolocations represented with latitude and longitude coordinates
in a JSON document in each KiiObject.
A geolocation can be stored as a JSON object for a key as shown in the figure below. You
can store multiple geolocations according to the specification of your service.

By having geolocations in KiiObjects, you can query KiiObjects in a rectangular area


specified by two points (GeoBox query) and in a circular area specified by the center and
radius of the circle (GeoDistance query). You can get a list of KiiObjects that are within an
area specified by a query condition using the location key.
A query condition using geolocations can be combined by logical operators such as AND and
OR with other query conditions, for example, that returns KiiObjects such that the score key
of each KiiObject has a value greater than 70.

You can handle a geolocation similarly to other custom fields. This is because a geolocation
is not a special attribute value for KiiObjects but a value in one of the data types in the JSON
format. Make use of geolocation data with the flexibility of the JSON format when designing
data according to the specification of your service.

Learn more...

 For more information about the geolocation feature, see "Managing Geolocations"
(Android, iOS, JavaScript, REST) in the programming guide.

Customizing Access Permissions


Kii Cloud uses scopes to define user permissions to access objects. You can adjust the
permissions by customizing an object's ACL (Access Control List).
When a user attempts to access a bucket, KiiObject, and so on, Kii Cloud checks if the user
has a permission by using the object's ACL.
An ACL in Kii Cloud is a whitelist that consists of permissions, that is, ACL entries that
define who can do what. With the Kii Cloud SDK and REST API, you can add and delete
ACL entries.
As with buckets and KiiObjects, topics used with the push notification feature and scopes
also have an ACL. You can customize any object's ACL with the Kii Cloud SDK and REST
API.
Each object's ACL defines permissions for the following operations:
Scope

 Create new buckets in the scope.


 Create new topics in the scope.

Bucket

 Create new KiiObjects in the bucket.


 Query KiiObjects in the bucket.
 Read KiiObjects in the bucket.
 Drop the bucket along with all KiiObjects inside.

KiiObject

 Read the KiiObject.


 Update and delete the KiiObject.

Topic

 Subscribe to the topic.


 Send push messages to the topic.

The permissions can be granted to specific users and groups, anonymous users, authenticated
users, and IoT-enabled things.
Access control is important to protect your data.
When you need to customize permissions, for example, to share data with specific users, you
can minimize the number of permitted users by using the object's ACL. Even if your mobile
app is hacked and attacked, the ACL protects saved data.

Learn more...

 For more information about access control, see "Securing Data"


(Android, iOS, JavaScript, REST) in the programming guide.

Push Notification
Kii Cloud provides a means of using push notifications. Push notifications allow you to easily
build features such as receiving a change in the server data and exchanging messages among
devices.
The push notification feature of Kii Cloud is built on the following technologies:

 For Android apps: FCM (Firebase Cloud Messaging)


 For iOS apps: APNs (Apple Push Notification service)
 For Android apps in China: JPush
 For Cordova apps: FCM and APNs
 For web apps: MQTT over WebSocket
 For Node.js apps: MQTT over the TCP socket

In addition to FCM and APNs that are commonly used for Android and iOS apps, you can
choose JPush for the China market where FCM is unavailable. You can also choose MQTT
and use the push notification feature on various platforms.
As shown in the diagram below, a push notification immediately informs a device of an event
that occurred on the server.
Usually, you need an application server to use the push notification feature in an environment
described as below. With Kii Cloud, you can use the push notification feature just by
implementing your mobile app and configuring Kii Cloud.

Kii Cloud supports the following three types of push notifications as server events. The JSON
message (payload) in the diagram depends on the values specific to each of these types and/or
parameters specified by the API and so on.

 Push to App Notification


 Push to User Notification
 Direct Push Notification

By making use of these push notifications, you can provide various features such as those for
synchronizing data among devices and exchanging messages in real-time on a chat app.
In order to implement the push notification feature, you need to understand the third-party
push notification technologies listed above in addition to the Kii Cloud features.
To help you to get started smoothly, this documentation site introduces the minimum
knowledge required for the implementation and explains the execution results of processes
that can exhibit a complex behavior. You can also make use of the push notification tutorial
and troubleshooting topics to accelerate the development process.

Learn more...

 For technical information about push notification, Kii Cloud features, and troubleshooting,
see "Managing Push Notifications" (Android, iOS, JavaScript, REST) in the programming
guide.
 The tutorials explain the initialization of the push notification feature of FCM, GCM, APNs,
and MQTT over WebSocket. See Push Notification Tutorials.

Push to App Notification


With the Push to App notification feature, you can receive a change to a bucket as a push
notification. Kii Cloud sends a push notification to subscribers when a KiiObject is created,
updated, and so on, in a subscribed bucket.
The Push to App notification feature works as below.

1. A user subscribes to a bucket so as to start monitoring the bucket for changes.


2. A change (event) occurs on a KiiObject in the bucket.
3. The subscriber receives a push notification on a device.

The payload of a push notification is in the JSON format and stores information such as the
changed bucket and KiiObject ID.

The user must be logged in to subscribe to a bucket. The subscription can be set and works as
below:

 A user can subscribe to multiple buckets. The user receives a push notification when a
change occurs in one of the buckets.
 A bucket can be subscribed to by multiple users. All the subscribed users receive a push
notification when a change occurs in the bucket.

If you do not want to create users for your mobile app, use the pseudo user feature.

Learn more...

 To learn about implementing the Push to App notification feature, see "Push to App
Notification" (Android, iOS, JavaScript, REST) in the programming guide.

Push to User Notification


With the Push to User notification feature, a mobile app user or the administrator can send a
message as a push notification. Let users create a topic that has a purpose and subscribe to it.
Kii Cloud sends a push notification to subscribers when a message is sent to the topic.
The message can contain any JSON string. This feature is appropriate for sending a message
to a user who has subscribed to a topic and synchronizing data among the mobile apps on
devices.
The Push to User notification feature works as below.

1. A user or the administrator creates a new topic.


2. Other users subscribe to this topic.
3. A user or the administrator sends a push message to the topic.
4. A push notification is sent to all the subscribers.

The user must be logged in to subscribe to a topic. The subscription can be set and works as
below:

 A user can subscribe to multiple topics. The user receives a push notification when a
message is sent to one of the topics.
 A topic can be subscribed to by multiple users. All the subscribed users receive a push
notification when a message is sent to the topic.

Any number of topics with any names can be created in the application scope, group scopes,
and user scopes. A created topic is subscribed to by the topic creator and other users allowed
by the ACLs of the scope and the topic.
Learn more...

 To learn about implementing the Push to User notification feature, see "Push to User
Notification" (Android, iOS, JavaScript, REST) in the programming guide.

Direct Push Notification


With the Direct Push notification feature, the application administrator can directly send a
message to a certain user. A message in the JSON format can be sent to a certain user through
the developer portal or the REST API.
Use the developer portal to send a message to a certain user. You do not need to implement a
subscription process in your mobile app but those for initializing the push notification feature
and handling a received notification.
Learn more...

 To learn about implementing the Direct Push notification feature, see "Direct Push
Notification" (Android, iOS, JavaScript, REST) in the programming guide.

Push Notification across Platforms


Kii Cloud can send push notifications across various push notification networks such as
FCM, JPush, APNs, and MQTT.
For example, if a user has an Android device and an iOS device, both the devices can receive
push notifications.
The Android device receives push notifications through FCM and the iOS device receives
those through APNs. When a push message is sent to a topic that the user has subscribed to in
Kii Cloud, a push notification is sent to the user's devices through FCM for the Android
device and APNs for the iOS device.
You can also limit the destination push notification network when a push notification is sent.
For example, you can send a message only to devices connected to FCM.
Kii Cloud allows you to send push notifications across platforms just by using the
subscription mechanisms of the Push to App and Push to User notification features. You can
focus on the implementation of your own service because it is unnecessary to implement
complex tasks related to sending messages such as that for managing destination platforms.

Development and production environments


With the push notification feature in Kii Cloud, you can use development and production
environments even if push notifications are sent to the push notification networks other than
APNs.
APNs has development and production environments as part of its specification. Kii Cloud
uniquely provides the two environments for the other push notification networks.
You can use the development and production environments for all the platforms. It is possible
to run tests such as sending a push notification only to the development environment
separately from the environment for the released mobile app.

Learn more...

 For more information about sending push notifications across platforms and identifying
development and production environments, see "Push Notification across Platforms"
(Android, iOS, JavaScript, REST) in the programming guide.
Server Extension
Kii Cloud supports the server extension feature for running your custom logics on the server.
All you need is to write your custom logics in JavaScript (we call it server code) and set it in
Kii Cloud. Once the server code is set, you can launch it directly from your client application
and auto-run it when the designated conditions are met.
From JavaScript code created as server code, you can call methods of the Kii Cloud SDK for
JavaScript and available libraries supported by the server code specification. You can run
your own logic without effects of other applications on the same server because server code
is executed in the sandbox.
Though server code has some limitations for security including the number of executable
steps, it allows you to freely access external servers and data on Kii Cloud via the Kii Cloud
SDK. Server code allows flexible implementations when a mobile app cannot cover your
requirements.
Executing server code does not decrease the security of Kii Cloud because server code runs
in the sandbox.
You do not need to be responsible for the server security because Kii maintains the execution
environment.

Functionality of Server Code


You can execute server code with the following four methods. Select the method that serves
your purpose well.

Method Description

Calls server code from the Kii Cloud SDK or the REST API and receives
Manual operation
the execution result as a return value.

Trigger-based Calls server code automatically when an event occurs such as an


server hook update to a user or a bucket.

Schedule-based
Calls server code automatically on a specified time.
server hook

Calls server code automatically when state data from a thing satisfies a
Thing-IF trigger
condition. This is an IoT feature of the Thing-IF SDK.

* For more information about the Thing-IF trigger, see Auto Execution with Triggers.
Server code consists of a JS file that contains a JavaScript program, and a server hook
configuration file that contains calling conditions of server hooks. If server code is executed
only manually, a server hook configuration file is unnecessary.
The following section introduces benefits of server code by examples of a manual operation
and a server hook.
Manual operation
With the manual operation method, you call server code registered on Kii Cloud from the Kii
Cloud SDK or the REST API and execute it on the server. The caller receives only the
execution result as a response.
You can prevent reverse engineering and unauthorized operations because server code is not
distributed among users. Additionally, you can protect data from unauthorized access by
restricting the ACL of the data because you can securely call server code with the
administrator right. If you allow access to KiiObjects only via server code, you can also hide
the process to update KiiObjects.

Example of a secure update

As an example of a secure update, suppose you use server code to manage the highest score
of a game. Assume the highest score is updated when the game ends.
When a client requests the server code to update the highest score, the client passes data that
gives the evidence for the score, such as when the player reached a checkpoint, in addition to
the player's score. You can evaluate the evidence data for any cheating with the server code.
You can also prevent unauthorized access including direct updates to KiiObjects by allowing
to update the highest score only with the administrator right.
The caller of the server code receives only the result that tells if a new record is set or not.

One of the benefits of server code is higher security.


As stated in this topic, you can prevent reverse engineering of your program and access
protected data with the administrator right.
Automatic execution with a server hook
There are two types of automatic execution with a server hook: execution by a trigger-based
server hook and that by a schedule-based server hook.
 With a trigger-based server hook, you can specify server code to be executed when
any of the following events occur. Server code is called according to the content of
the server hook configuration file.

Target Event

Bucket A KiiObject is created, deleted, or updated in the target bucket.

A user is created or deleted, a user's email address or phone number is


User authenticated, a user's password is reset or updated, or a user's
attributes are updated.

Group A group is created or added, or a member is added or removed.

A thing is registered or unregistered, enabled or disabled, an owner is


Thing
added or removed, or information of a thing is updated.

Installation A device is installed or uninstalled for receiving push notifications.

 With a schedule-based server hook, you can specify server code to be executed and its
execution time. The execution time can be set by a combination of a month, a day of
the month, hour, minute, and a day of the week, its repetition, or a list of
combinations. For example, you can set a simple execution time profile such as every
hour as well as a complex one such as every 11:00 and 16:00 on Saturdays and
Sundays.

Example of a server hook

As an example of a trigger-based server hook, assume a campaign where a new user can
receive a gift in the app. This example calls server code to update data in a new user's scope
when the user is created.
In the server hook configuration file, the user creation event is associated with a function in
specific server code. When the server code is called, the new user is passed as an argument of
the function. Then the server code can update a KiiObject in the user's scope.
With a server hook, you can ensure to perform a specific operation for an event. User
creations performed in your Kii Cloud application are all captured without omissions.
Moreover, a server hook decreases a risk of incomplete processing caused by a
communication error because communications within Kii Cloud are more stable than those
between the mobile app and Kii Cloud through public networks and Wi-Fi (Note that a retry
logic is required if the operation must be fully performed).
Unlike a mobile app, you do not need to deploy or install server code. You can replace all the
previous logics to new ones when a new version of server code is activated. You can
immediately enable a business logic that often changes its behaviors like a campaign for all
users.
Completeness and operability are also improved by using server code.
As stated in this topic, server code helps to perform operations completely without fail and to
immediately update the program without deployment to clients.

Learn more...

 For more information about features supported by server code, see Functionality of Server
Code.
 For the implementation of server code, see Server Code Syntax. For more information about
the server hook configuration file, see Server Hook Configuration File.
 For benefits of server code, see Advantages of Server Extension in the first topic of the
Server Extension Programming Guide.

Managing Server Code


In order to manage server code, install the command line tool on your development
PC and run management commands. Server code is protected from unauthorized
operations because you need the administrator's right to run the command line tool.
Server code and a server hook configuration file are managed as a pair in Kii Cloud.
Such a pair is registered and activated as a version. The pairs registered in the past
are maintained as history. You can switch to an old version by one command.

Only one set of server code can be activated at a time. When new server code is
deployed, it is set and activated as the default version. At this point, the previous
version is deactivated as an old version. When you execute server code manually or
automatically, the currently active version is executed.
The history of pairs of server code and server hook configuration files is maintained
in Kii Cloud. You can revert to the previous version and continue operation if a
problem is found in a new set of server code.
Application Analytics
The application analytics feature will let you aggregate and analyze various data generated by
your mobile app. By leveraging the analysis results, for example, you will be able to plan
which features you need to introduce and which feature you need to improve in the next
release.
Kii Cloud provides two methods for analyzing your app:
 Analysis using the developer portal
o Basic Analytics
You can analyze the usage of your app by checking the transition of the
number of users, KiiObjects, and things with graphs.
o Flex Analytics
You can analyze a various aspect of your app by checking the transition of
arbitrary app data with graphs. You can select either app data (i.e., KiiObject
values) and event data (i.e., analysis-specific data) as the analysis target.
 Integration with an External Analytics Foundation
This is a custom feature for performing more complex analysis with an external
analytics foundations like Amazon Redshift.
The application analytics is a feature for developers and application administrator who can
log in to the developer portal. If you want to show analysis result graphs to end users, you
need to implement the feature in your mobile app or as a Web application. For some hints,
see Data Management and Managing State History for IoT.

Basic Analytics
The basic analytics is a developer portal feature for checking the application usage quickly. It
is "out-of-the-box" analytics, so you can start using it without any special configuration.
The basic analytics shows the transitions of the number of users, KiiObjects, and things
registered in your application in graphs.
The above screenshot is a dashboard screen that you will see right after selecting an
application on the developer portal. The graphs showing the transition of the number or users
and KiiObjects will be displayed as the default screen.
Once you move to the management screen, you can check the transition of users, KiiObjects
and things at any time period.
The basic analytics allows you to grasp the usage of your app without any configuration.
For example, you can evaluate the effect of campaigns and events by checking the transition
of users. You can also check the transition of KiiObjects to estimate how your users are using
your app.

To learn more...

See "Basic Analytics" (Android, iOS, JavaScript, REST) in the reference section to learn
more about the basic analytics.

Flex Analytics
The flex analytics allows you to analyze your application with the customization. As
compared to the basic analytics with which you can only use some predefined metrics like the
number of users and KiiObjects, the flex analytics allows you to define your own rules on the
data generated by your application. By defining your rules, you will be able to analyze your
application from the various point of view.

Purpose
Kii Cloud flex analytics is a feature for analyzing how the number and value of application
data have changed in one day. You can check the transition of any field in data as a graph on
the developer portal or with your custom logic implemented in your mobile app.
Here are some examples of how you can leverage the analytics:

 Aggregate the results of questionnaires and campaigns that are carried out continuously and
evaluate the satisfaction level of users by slicing the results with some parameters like age
group, gender, and interest. You will be able to evaluate how the satisfaction level of the
target customers is changing.
 Monitor the usage of mobile app features over time with graphs and determine which
features you need to focus on development.
 Monitor the transition of the game score and the passage level of the specific event with
graphs and validate the balance adjustment of the game.

Note that the developer portal does not support advanced analysis functions such as
automatically extracting the correlation between multiple fields and predicting future values
by learning past data. Consider using Integration with an External Analytics Foundation if
you need to conduct these types of analysis. You can export a portion of data stored in Kii
Cloud to an external analytics foundation and start more full-scale analytics there.

Data source for analytics


Kii Cloud allows you to use app data and event data as the data source.
 App data
The data in a specified bucket becomes a target for the analysis. Kii Cloud acquires all
KiiObjects in the bucket and aggregates the values of the specified key every 24
hours.
 Event data
The analysis-specific data sent from your mobile app becomes a target for the
analytics. The values of the specified key in the transmitted event data are aggregated
every 24 hours.
For app data, unchanged data continues to be aggregated and analyzed after the next day. For
event data, the data is only aggregated and analyzed on the day when it is sent. Select these
two types of data appropriately so as to match with the purpose of your analysis.
You will want, for example, to use the app data analysis if you want to analyze the daily
transition of your game's "all time" high score. On the other hand, you will want to use the
event data analysis if you want to check the daily transition of your game's "daily" high score.

Analytics feature
When performing the application analysis, the target data is extracted and aggregated from
the data source following a rule set in the developer portal.
You can evaluate the aggregated results on the developer portal. You can also get the result
as an output of the SDK and leverage the result in a different mobile app (i.g., a management
tool).
When setting a rule, you will specify the target field in the data source that is to be used as
the y-axis of the graph. You will also specify how you want to aggregate the field value. The
available aggregation methods are: averaging the field values, summing the field values,
getting the maximum value, getting the minimum value, and counting the data.
You can also set some dimensions for grouping the aggregated result. For example, suppose
that we are analyzing the average temperatures from a series of JSON objects that stores a
city name, weather, and temperature. By setting the city name and weather as dimensions, we
can group the graph of the average temperature transition by city and by weather.
When checking the analyzed result, you can further drill down the graph by adding some
filters. By applying filters, you will be able to plot only the data that has the designated
values in the designated fields.
For example, the aggregated results grouped by weather in Dimension above does not tell
clear characteristics of the temperature data. The figure below shows an example of applying
filters for focusing on one city "Tokyo" and showing only the data with its weather "rainy" or
"cloudy". As shown in the figure below, you can visually perceive the tendency that the
average temperature of cloudy days (light blue) is higher than that of rainy days (green) by
showing aggregated results only from rainy and cloudy days in Tokyo.

You can leverage dimensions and filters to verify the correlation between multiple field
values.
In the above example, you can verify the relationship between cities and temperature and the
stability of the temperature in regions. You will be able also to find the tendency like "the
temperature in cloudy days tends to be higher than the one in rainy days" by keep analyzing
with the graph.

To learn more...

 See "Flex Analytics" (Android, iOS, JavaScript, REST) in the reference section to
learn more about the flex analytics.
 The application analytics is a feature for developers and application administrator. If
you want to show an analysis result graph to end users, you need to implement your
mobile app or a Web application by leveraging Data Management and Managing
State History for IoT.

Integration with an External Analytics


Foundation
Kii provides a feature to integrate with an analytics foundation such as Amazon Redshift for
more full-scale analytics.
You can export object updates in Kii Cloud in near real-time through Apache Kafka so that
exported data from Kii Cloud can be processed in various ways on an external analytics
foundation.
Integration with an external analytics foundation is an optional feature which assumes paid
customization. Contact support@kii.comfor more information. Integreation with an analytics
foundation requires detailed knowledge about the analytics foundation and Kafka and
development of bridge software based on such knowledge.
See the below figure for a configuration example of integration with an external foundation.
Set up an analytics foundation external to Kii Cloud and export existing KiiObjects in Kii
Cloud to the analytics foundation. You can send differential data created from changes in
KiiObjects to the analytics foundation as follows.
1. Kii Cloud has a Kafka cluster and producer. If your application setting is changed,
Kafka will collect differential data created by adding, updating, and deleting
KiiObjects with mobile apps and so on for all KiiObjects in all scopes.
2. Outside of Kii Cloud, develop bridge software to register data to the analytics
foundation. This bridge software retrieves the differential data as Kafka records by
using the Kafka consumer library. Then, the bridge software filters the data to register
only data necessary for analytics to the analytics foundation.
Thie flow allows synchronization of data on the analytics foundation and Kii Cloud in near
real-time and you can analyze the latest information. The timing and frequency of data
retrieval depend on the implementation of the bridge software. You can retrieve differential
data from Kafka at timing when you analyze the data.

Security
Security consideration is important in the process of mobile app development and operation.
This section explains the security in Kii Cloud.
In addition to detailed technical information on security, we provide technical tips for
implementing your apps. These tips cover topics like transactions and performance handling.
For details, see "Implementation Tips" in the reference guide
(Android, iOS, JavaScript, REST).

Kii Cloud security


Here is a list of Kii Cloud security aspects that relate to your mobile app development.
 Communication channel security
The communication channel between Kii Cloud and devices is secured with the
SSL/TLS protocol. API requests made by Kii Cloud SDK and REST API are made
via HTTPS. In addition, the MQTT for IoT can also leverage the SSL/TLS based
protocol.
 Server security
Kii Corporation is fully responsible for ensuring the security of the server operations,
such as setting server permissions and applying security patches. Developers thus do
not need any special consideration on the server security. As described in Server
Extension, developers are not responsible for any server operation even if they run
their custom logic on the server.
 Application security
When designing an app that integrates Kii Cloud features, developers need to consider
security at the application level. We will explain the basics in the remaining sections
of this page.

Application security
For ensuring the security of a Kii Cloud application, the first thing to consider is the security
of the data saved by users.
The data saved by mobile apps are designed to be protected by each user's password.

 Data saved in a user scope cannot be accessed by anyone other than the user themselves.
 Data saved in a group scope cannot be accessed by anyone other than the members of the
group.

Even if an attacker has knowledge of the application design or has its source code, the
attacker cannot access the user's data unless he knows the password of the target user.
As an open system, Kii Cloud is disclosing the specification for accessing the server to the
public. Therefore, an attacker can reproduce the same procedures for accessing the API by
decompiling your mobile app. Since each user's data is protected by their password, however,
the attacker cannot access the data.
A mobile application that conforms to the basic design model of Kii Cloud will be a secure
application. Normally, the mobile app will create a user and store their data in their scope.
The data stored with this design will be resilient from attack.
There are other points, besides from storing data, where some security consideration is
required. We will provide the corresponding design tips separately in the reference guides.

Comparison with proprietary server


The security of the Kii Cloud is tighter than systems that adopt the "Obfuscated
implementation" as the basis of security.
Some people think that a proprietary server that hides its communication specification is safer
than an open system like Kii Cloud. This is not true since relying solely on the obfuscated
implementation is fairly vulnerable. A motivated attacker can analyze a mobile app without
any time limitation and by any means. As long as the attacker can obtain an execution
module of your client, the fact that the source code or specification is hidden is trivial.
On the assumption of an open specification, Kii Cloud ensures its security by the user
authentication and access authorization mechanisms. As mentioned above, an attacker cannot
access user's data even if they know how to access them.
It is possible to achieve the security level equivalent to the Kii Cloud on a proprietary server.
A cost for validating and testing the server security, however, tends to be treated less since
the security does not directly contribute to the functionality and product values of the final
service. Kii Cloud treats the security seriously by regarding the security as a part of its
functionality; we conduct sufficient amount of verification and testing for ensuring the
security.
SDK License Information
The following pages describe the SDK license information.

 Kii Cloud SDK for Android


 Kii Cloud SDK for iOS
 Kii Cloud SDK for JavaScript

Kii Cloud SDK for Android


Target SDK
 Android Cloud SDK available on Kii Developer Console. (PhotoColle SDK is not
included.)
 Android Cloud SDK available on bintray.

License applied to the SDK


Please refer our Terms and Conditions. (For Japanese users, please refer 利用規約.)

Open Source Software included in the SDK


MIT License

scribe-java

The source code is compiled with the SDK. To avoid a collision, the package name has been
modified. The API using scrive-java has been deprecated now.
Since we include the source code of older version, the license description may differ from the
latest version of scrivejava.
The MIT License

Copyright (c) 2010 Pablo Fernandez

Permission is hereby granted, free of charge, to any person obtaining a


copy
of this software and associated documentation files (the "Software"), to
deal
in the Software without restriction, including without limitation the
rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Das könnte Ihnen auch gefallen