Samples
last update 2015-3-26

Puzzle App

Puzzle App

About This App

Users register with their email address, and login with Login ID and Password.
There are several stages for the puzzle game.
Every time users clear the stage, in accord with the time took, names will appear on ranking lists.
There are “Time Ranking” list and “First-Come Ranking” list.
In order to keep track of orders for “First-Come”,
we will be using “Sequence API” provided by Appiaries.

Appiaries API Services Used

Project Files

You can get project files from Github.

Appearance

Login
Register
Introduction
Home
Play
Sample
Result
Time Ranking
First-Come Ranking

Server-Side Collections Used

Entity System Name Type Description Note
Introduction Introductions JSON Collection Service description texts shown to users after registration. Each object stands for 1 page.
App Users (App User) No collections to be created but App User feature to be used. Stores App User information using this Puzzle App. In each App User data, also holds attribute data “nickname”.
Stages Stages JSON Collection Stores settings for all stages.
Images Images File Collection Puzzle image files (the whole image is to be stored instead of divided pieces)
Time Ranking TimeRanking JSON Collection A type of ranking for the time it took for a user to clear each stage. Shorter the time record, higher on the ranking list.
First-Come Ranking FirstComeRanking JSON Collection Faster the user clears the given stage, ranked higher on the record. * Sequence API to be used.
First-Come Ranking Sequence FirstComeRankingSeq Sequence Collection Issues a sequence value for each user. Reset when calculated.

“Introductions” Collection

(JSON Collection)

Stores the setting information for all stages.

Example:

Object ID: 3dd923a7ffd965cde4

Object ID: 7fb6c160243e693ccf

Object ID: bff972861edee11faf

Object ID: a8981c169d1615f738

App Users (This is not a JSON collection)

No collections to be created but App User feature to be used.

This is not a JSON collection.
New users are registered using Appiaries “App User” feature from the client app.
Each “App User” can optionally hold additional JSON data,
and we set user’s attribute information such as “nickname”.

Login ID Authentication Authenticate
Email Authentication Authenticate
Registering Email Address Allow
Anonymous Authentication Do not allow

App users are registered from the client side requesting “App User API” on Appiaries.
When registering, the client app also needs to store the user’s attribute data,
namely, “auto_login” and “nickname”.

Example:

Object ID: (randomly generated because objects are created from the app)

“Stages” Collection

(JSON Collection)

Stores settings for all stages.

Example:

Object ID: ca010752678373e784

Notice “a3701e6613c731c1f4″ refers to corresponding image object.

Object ID: 0345122c672e356813

Notice “a19613a99b3886c4f6″ refers to corresponding image object.

If you change the server setting on how you split the puzzle image, it displays the game accordingly.





“Images” Collection

(File Collection)

Puzzle image files (the whole image is to be stored instead of divided puzzle pieces).

Example:

Object ID: a3701e6613c731c1f4

This is the image object for “Stage 1″.

Object ID: a19613a99b3886c4f6

This is the image object for “Stage 2″.

“TimeRanking” Collection

(JSON Collection)

A type of ranking for the time it took for a user to clear each stage.
Shorter the time record, higher on the ranking list.
Objects are not registered via Appiaries control panel,
but from the client app.
Each object which belongs to this collection therefore has randomly generated Object ID.

Example:

Object ID: (randomly generated because objects are created from the app)

Meaning, Melissa has cleared the stage “ca010752678373e784″ (which is “Stage 1″) in 13 seconds.

“FirstComeRanking” Collection

(JSON Collection)

Faster the user clears the given stage, ranked higher on the record.
Objects are not registered via Appiaries control panel,
but from the client app.
Each object which belongs to this collection therefore has randomly generated Object ID.
* Sequence API to be used.

Example:

Object ID: (randomly generated because objects are created from the app)

Meaning, Rodrigo has cleared the stage “ca010752678373e784″ (which is “Stage 1″) in 2 seconds,
scoring the first place on the ranking list.

FirstComeRankingSeq Collection

(Sequence Collection)

Issues a sequence value for each user.
Reset when calculated.

Decrement Sequence Value Yes
Initial Sequence Value 1

Other Server-Side Settings

App ID

When you add a New App on Appiaries, choose “puzzle” for its App ID.
We talk about this in the next section [App Settings],
but this is simply because the sample source codes use “puzzle” as a default.
There is no problem to change the App ID as you like.
Please make sure, if you want a different App ID,
to also change the one defined in the setting file discussed in [App Settings].

Client-Side Source Codes

(Android)

Constants are defined in the following file:

com/appiaries/gallery/common/Constants.java

Let’s look at each definition.

You specify “App Token” to APIS_APP_TOKEN to authenticate client apps to connect to Appiaries.
“App Token” is required whenever you make requests to Appiaries APIs.
Appiaries’ demo App Token is provided by default.
(See also, “Where Is My App Token?”)

APIS_DATASTORE_ID is your “Datastore ID”.
Just as you need “App Token”, you need “Datastore ID” to make any requests to Appiaries APIs.
Notice you have “appiaries_sample” set in your downloaded sample code.
Specify the appropriate Datastore ID for the contract plan you have.
For instance, specify “_sandbox” if you are working on sandbox environment.

APIS_APP_ID your “App ID”. This is what identifies your app.

(iOS)

Constants are defined in the following file:

Puzzle/Library/PUZConfigurations.h

Let’s look at each definition.

You specify “App Token” to PUZAPISAppToken to authenticate client apps to connect to Appiaries.
“App Token” is required whenever you make requests to Appiaries APIs.
Appiaries’ demo App Token is provided by default.
(See also, “Where Is My App Token?”)

PUZAPISDatastoreId is your “Datastore ID”.
Just as you need “App Token”, you need “Datastore ID” to make any requests to Appiaries APIs.
Notice you have “appiaries_sample” set in your downloaded sample code.
Specify the appropriate Datastore ID for the contract plan you have.
For instance, specify “_sandbox” if you are working on sandbox environment.

PUZAPISAppId is your “App ID”.
This is what identifies your app.