NAV Navbar

PA SDK Guide

latest version: v2.2

javascript

Introduction

Welcome to Pocket Arena SDK documentation.

How to use

1 Insert script in the head tag of your game.

<head>
    <script src="jquery-2.1.1.min.js"></script> <!-- jquery required-->
    <script type="text/javascript" src="EmojiGamesPASDK.min.js"></script>
</head>

2 Create a new instance of SDK

var pasdk = new EmojiGamesPASDK({
    gameId : 'xxxxxx'    //game id
});

3 After below onComplete function is triggered, you can just call any API.

pasdk.ISREADY(function(){ 
        //onComplete
        console.log('sdk is ready. Now SDK API is available.') 
    }, function(err){ 
        //onError
        console.log(err, 'error occurred during initializing.') 
    });
  1. Insert script in the head tag of your game.
  2. Create a new instance of SDK
  3. After onComplete function of ISREADY is triggered, you can just call any SDK API.

Common API

new EmojigaGamesPASDK

new EmojigaGamesPASDK( options )

var options = {
    gameId : 'xxxxx',
    useLeaderboard : false
}
var sdk = new EmojiGamesPASDK(options)

new EmojigaGamesPASDK( options )

Create a PA SDK instance.

Arguments

Argument Type Default Description
options Object - API call is success

options argument

Type Key Default Description
String gameId * - Game ID. You can get this id when you register your game.
Boolean useLeaderboard false This option works only for the game that leaderboard is set to use. You can set leaderboard when you register your game.
true Use leaderboard.
false Not use.

Return

Type Description
EmojiGamesPASDK SDK instance

ISREADY

ISREADY( onComplete, onError )

pasdk.ISREADY(function() {
    //onComplete arg

}, function(err){
    //error arg
    console.log('error object', err)
})

ISREADY(onComplete, onError)

SDK is ready to use. All functions of PA SDK should be called after this API is triggered.

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

GETLEADERBOARDTYPE

GETLEADERBOARDTYPE()

var res = pasdk.GETLEADERBOARDTYPE()

console.log('res', res)     // 'res win'

GETLEADERBOARDTYPE()

Get leaderboard type.

Return value

Type Value Description
String win Rank is based on number of win
score Rank is based on stage clear score or stage number.

SIGNIN

SIGNIN( type, params, onComplete, onError )

email type

pasdk.SIGNIN('email', {email : 'me@emojigames.io', password : '#12345678'}, 
    function(player, poc){
    //onComplete
    //console.log('player', player)     //see PLAYER.GETINFO
    console.log('poc', poc)             //'poc null' | 'poc 28342'
}, function(err){
    //onError
    console.log('err', err)
})

sns type

pasdk.SIGNIN('sns', {snsName : 'facebook'}, 
    function(player, poc){
    //onComplete
    //console.log('player', player)     //see PLAYER.GETINFO
    console.log('poc', poc)             //'poc null' | 'poc 28342'
}, function(err){
    //onError
    console.log('err', err)
})

phone type

pasdk.SIGNIN('phone', {number : '1112223333', countryCode : '82', password: '#12345678'}, 
    function(player, poc){
    //onComplete
    //console.log('player', player)     //see PLAYER.GETINFO
    console.log('poc', poc)             //'poc null' | 'poc 28342'
}, function(err){
    //onError
    console.log('err', err)
})

SIGNIN( type, params, onComplete, onError )

User sign in. You can either make your own UI or use UI.SIGNIN API.

type argument

Sign in type

Type Value Description
String email For email sign in
sns For SNS account sign in (Google, Facebook)
phone For phone number sign in

params argument

Parameters to send to server. Key varies depending on the type argument.

For email type

Type Key Description
String email Email address
String password Password. Up to 8 characters

For sns type

Type Key Value Description
String snsName facebook
google

For phone type

Type Key Description
String number Phone number
String countryCode Phone number country code.
ex) 1 for US/Canada, 41 for Switzerland
String password Password. Up to 8 characters

onComplete argument

Type Description
Function Triggered when call is success. It returns below arguments.
Type Argument Description
Object player Player data. See PLAYER.GETINFO
Number/null poc POC balance

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

SIGNUP

SIGNUP( type, params, onComplete, onError )

email type

pasdk.SIGNUP('email', {email : 'me@emojigames.io', password : '12341234', nickname: 'My Nickname', vcode: '1234'}, 
    function(player, poc){
    //onComplete
    //console.log('player', player)     //see PLAYER.GETINFO
    console.log('poc', poc)             //'poc null' | 'poc 28342'
}, function(err){
    //onError
    console.log('err', err)
})

sns type

pasdk.SIGNUP('sns', {snsName : 'facebook'}, 
    function(player, poc){
    //onComplete
    //console.log('player', player)     //see PLAYER.GETINFO
    console.log('poc', poc)             //'poc null' | 'poc 28342'
}, function(err){
    //onError
    console.log('err', err)
})

phone type

pasdk.SIGNUP('phone', {number : '1112223333', countryCode : '82', password: '@1231234', nickname: 'My Nickname', vcode: '1234'}, 
    function(player, poc){
    //onComplete
    //console.log('player', player)     //see PLAYER.GETINFO
    console.log('poc', poc)             //'poc null' | 'poc 28342'
}, function(err){
    //onError
    console.log('err', err)
})

SIGNUP(type, params, onComplete, onError)

User sign up. You can either make your own UI or use UI.SIGNUP API.

type argument

Sign up type

Type Value Description
String email For email sign in
sns For SNS account sign in (Google, Facebook)
phone For phone number sign in

params argument

Parameters to send to server. Key varies depending on the type argument.

For email type

Type Key Description
String email Email address
String password Password. Up to 8 characters
String nickname Player's nickname
String vcode Verification code. The code can be received via SENDVERIFICATIONCODE API. The API will send an email that contains the code.

For sns type

Type Key Value Description
String snsName facebook
google

For phone type

Type Key Description
String number Email address
String countryCode Phone number country code. ex) 1 for US/Canada, 41 for Switzerland
String password Password. Up to 8 characters
String nickname Player's nickname
String vcode Verification code. The code can be received via SENDVERIFICATIONCODE API. The API will send a sms that contains the code.

onComplete argument

Type Description
Function Triggered when call is success.
Type Argument Description
Object player Player data. See PLAYER.GETINFO
Number poc POC balance

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

RESETPASSWORD

RESETPASSWORD( email, onComplete, onError )

pasdk.RESETPASSWORD ( 'me@emojigames.io', 
    function(){
    //onComplete
}, function(err){
    //onError
    console.log('err', err)
})

RESETPASSWORD( email, onComplete, onError )

Send an email to reset password.

email argument

Type Description
String User's email address

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

SENDVERIFICATIONCODE

SENDVERIFICATIONCODE( method, id, phoneCountryCode, onComplete, onError )

email method

pasdk.SENDVERIFICATIONCODE ( 'email', 'me@emojigames.io', null, 
    function(){
    //onComplete
}, function(err){
    //onError
    console.log('err', err)
})

sms method

pasdk.SENDVERIFICATIONCODE ( 'sms', '123456789', '41', 
    function(){
    //onComplete
}, function(err){
    //onError
    console.log('err', err)
})

SENDVERIFICATIONCODE( method, id, phoneCountryCode, onComplete, onError )

Send an email or sms to verify a new account.

method argument

Type Description
String Type to register an account. email or sms

id argument

Type Description
String User ID to verify

For email method

Description
Email address

For sms method

Description
Phone number

phoneCountryCode argument

Type Description
String ex : 41 for switzerland, 1 for US/Canada

For email method

Description
null or undefined

For sms method

Description
phone country code

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

POCPURCHASE

POCPURCHASE( gameShopNo, onComplete, onError )

pasdk.POCPURCHASE(2, 
    function(){
    //onComplete
}, function(err){
    //onError
    console.log(err) 
});

POCPURCHASE( gameShopNo, onComplete, onError )

Request exchange POC for items or game currency such as Ruby. The item can be various depending on game.

gameShopNo argument

Type Description
Number The shopNo value received from GETSHOPINFO

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

GETSHOPINFO

GETSHOPINFO( onComplete, onError )

pasdk.GETSHOPINFO(function(returncode, poc, gameshop){
    //onComplete
    console.log('success', returncode, poc, gameshop);   //success 200, 4, see below about gameshop array
}, function(err){ 
    //onError
    console.log(err) 
});

gameshop object list

[{
    "shopno":"2",
    "title":"item 1",
    "itemimage":"https://ipascf.pocketarena.com/pa/ruby01.png",
    "itemamount":"1000",
    "pocamount":"10"
},{
    "shopno":"3",
    "title":"item 2",
    "itemimage":"https://ipascf.pocketarena.com/pa/ruby02.png",
    "itemamount":"5500",
    "pocamount":"50"
}]

GETSHOPINFO( onComplete, onError )

Get info that exchanges POC for items or game currency such as Ruby. The item can be various depending on game.

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Number returncode 200 : User verified.
401 : User needs to verify the account
Number poc User's POC balance
Array gameshop gameshop list. See below

gameshop object

Type Key Description
String shopno Shop unique id
String title Shop name
String itemimage Shop iamge
String itemamount Amount to buy
String pocamount Required POC to buy

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

GETREWARDEXP

GETREWARDEXP( onComplete, onError )

pasdk.GETREWARDEXP(function(exp, poc){

    //onComplete
    console.log(exp, poc) //87 18

    }, function(err){

    //onEror
    console.log('err', err) 
});

GETREWARDEXP(onComplete, onError)

Get user’s POC reward exp and amount to get when the exp reaches 100.

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Number exp User's level experiece. in percent
Number poc Amount of POC that user will gain when current exp reaches next level. (ex : x18). /n Returns null, If user has not done phone verification.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

GETREWARDPOC

GETREWARDPOC( params, onComplete, onError )

// When 'GAME.REPORTSCORE' is called...  
pasdk.GAME.REPORTSCORE(10, 0, 1, function(rewardpoc){

    //if 'rewardpoc' is returned
    if (rewardpoc) {

        //give POC as a reward to the user
        pasdk.GETREWARDPOC(null, function(poc){
                //onComplete
                console.log(poc)    //17
            }, function(err){
                //onError
                console.log('err', err) 
            });

    }else {

        // do something necessary ...

    }

}, function(err) {
    //onError
    console.log('err', err) 
})

GETREWARDPOC(params, onComplete, onError)

Get POC reward after a game when the POC exp reaches 100. Please note that this API must be called when GAME.REPORTSCORE returns rewardPoc.
Instead, you can use UI.REWARD, it will take care of this process.

params argument

Type Description
Object / Null Optional settings
Type Key Default Description
String mode reward reward or check

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Number poc POC balance user is going to get when exp reaches 100

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

OPENLINK( siteName, pageName )

wallet

//redirect to PA Wallet website
pasdk.OPENLINK('wallet')

emojigames

//redirect to Emojigames website
pasdk.OPENLINK('emojigames');

//redirect to Emojigames website's eSports result history page
pasdk.OPENLINK('emojigames', 'esportsHistory');

//redirect to Emojigames website's eSports leaderboard page
pasdk.OPENLINK('emojigames', 'esportsLeaderboard');

OPENLINK(siteName, pageName)

Open PA Wallet or EmojiGames website page.

siteName argument

Type Value Description
String wallet Redirect to PA Wallet website in new tab.
emojigames Redirect to EmojiGames website in new tab.

pageName argument for emojigames

Type Value Description
String esportsHistory Redirect to eSports result history page of Emoji Games website in new tab.
esportsLeaderboard Redirect to eSports leaderboard page of Emoji Games website in new tab.

Account API

PLAYER.GETINFO

PLAYER.GETINFO()

pasdk.PLAYER.GETINFO()    //see below

player object : for player signed in

{
    "country":"Switzerland",
    "countryCode":"CH",
    "email":"me@emojigames.io",
    "idType":"email",
    "image":"https://pacoin.pocketarena.com/upload/player/image/NrPtCkznLubJ.jpg",
    "isVerified":true,
    "level":5,
    "nickname":"Spike Kang",
    "rewardExp":{
        "POC":18,
        "exp":87
    }
}

player object : for player who is not signed in

{
    "rewardExp" : 87,
    "countryCode" : "CH",
    "country" : "Switzerland",
    "isAnonymous": true
}

PLAYER.GETINFO()

Get player’s information such as email, name, and so on. isAnonymous is returned only for player who is not signed in.

Return value

Type Description
Object if player is not signed in. isAnonymous is returned for non-signed player only.

player object : for player signed in

Type Key Key Description
String country Player country
String countryCode Player country code
String email Player email
String idType Determine if it's SNS account or email account
email or sns
String image Player profile image
Boolean isVerified true if player finished phone/email verification
Number level Player level
String nickname Player nickname
Object rewardExp Player's POC and level exp info
Number POC Player's POC amount
Number exp Player's level exp in percent

player object : for player who is not signed in

Type Key Description
Number rewardExp Player's level exp info
Boolean isAnonymous true always, since this key is for non-signed player
String country Ex) Player's country. ex) Switzerland.
String countryCode Ex) Player's country code. ex) CH.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.SETINFO

PLAYER.SETINFO( nickname, countryCode, currentPassword, newPassword, onComplete, onError )

pasdk.PLAYER.SETINFO('Brandon Jeong', 'KR', '12341234', '12341234', 
    function(){
    //onComplete
    console.log('success');
}, function (err) {
    //onError
    console.log('err', err);
});

PLAYER.SETINFO(nickname, countryCode, currentPassword, newPassword, onComplete, onError)

Set player’s information such as email, name, birthday, and gender.

nickname argument

Type Description
String / Null null if player is not signed in.

countryCode argument

Type Description
String* Required. Player's country code

currentPassword argument

Type Description
String Player's current password. At least 8, and up to 50 characters

newPassword argument

Type Description
String New password that player set to change. At least 8, and up to 50 characters

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.GETACTIVITY

PLAYER.GETACTIVITY( onComplete, onError )

pasdk.PLAYER.GETACTIVITY(function(activity){
    //onComplete
    console.log('res', activity)     //see below 'activity' object
}, function(err) {
    //onError
    console.log(err)
});

activity object

{
    "draw":7,
    "highscore":36,
    "lastAccess":"2018-10-17T02:50:08-07:00",
    "lose":8,
    "win":39
}

PLAYER.GETACTIVITY(onComplete, onError)

Get player’s PA activity statistic such as number of wins, lose, and last access time.

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.GETMYPOC

PLAYER.GETMYPOC( onComplete, onError )

pasdk.PLAYER.GETMYPOC(function(balance){
    //onComplete
    console.log('res', balance) //4
}, function(err) {
    //onError
    console.log(err)
});

PLAYER.GETMYPOC(onComplete, onError)

Get current POC balance

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Number / null balance POC balance player currently has. Returns null, if player has not done phone verification.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.COUNTNEWMESSAGES

PLAYER.COUNTNEWMESSAGES( onComplete, onError )

pasdk.PLAYER.COUNTNEWMESSAGES(function(amount){
    //onComplete
    console.log('res', amount); //4
}, function(err) {
    //onError
    console.log(err);
});

PLAYER.COUNTNEWMESSAGES(onComplete, onError)

Check if user has new messages or not. It returns amount of new(unread) messages.

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Number amount Total number of new/unread messages. 0, if none.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.GETMESSAGE

PLAYER.GETMESSAGE( limit, page, onComplete, onError )`

pasdk.PLAYER.GETMESSAGE(null, null, function(list, hasNext){
    //onComplete
    console.log('success', list, hasNext);  // success (see below for list), true
}, function (err) {
    //onError
    console.log('err', err);
});

notification object

{
  "notificationno":"1",
  "notificationtype":"1",
  "title":"Notice Title",
  "description":"Notice Description",
  "pocamount":null,
  "isread":false,
  "registdate":1523976927
}

messages object

{
  "messageboxno":"1",
  "messageboxtype":"1",
  "winnertype":"2",
  "title":"Message Title",
  "description":"Message Description",
  "isread":false,
  "registdate":1523976927
}

prizes object

{
  "prizeno":"1",
  "prizetype":"1",
  "title":"Prize Title",
  "description":"Prize Description",
  "isread":false,
  "registdate":1523976927,
  "expiredate":1523976927
}

PLAYER.GETMESSAGE( limit, page, onComplete, onError )

Get player's messages

limit argument

Type Description
Number / null Amount of messages to display in a page. default 10

page argument

Type Description
Number / null Page number to load. default 1

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Object list List of messages. See list object below.
Boolean hasNext true there are more pages. false there is no more pages.

list object

Type Key Description
Array notices List of notice object
Array messages List of message object
Array prizes List of prize object

notification object

Type Key Description
String notificationno Notification number. Unique.
String notificationtype Notification type. 1 : system notice, 2 : reward via eSports
String title Title
String description Description
String\Null pocamount POC amount
Boolean isread Status whether the message is read or not. true if it's read, otherwise false
Timestamp registdate Registered date

messages object

Type Key Description
String messageboxno Message number. Unique.
String messageboxtype Message type. 1 : system notice, 2 : reward via eSports
String winnertype Winner type. 1 : Team winner, 2 : Final winner eSports
This is for eSports games.
String title Title
String description Description
Boolean isread Status whether the message is read or not. true if it's read, otherwise false
Timestamp registdate Registered date

prizes object

Type Key Description
String prizeno Prize number. Unique.
String prizetype Prize type. 1 : system notice, 2 : reward via eSports
String title Title
String description Description
Boolean isread Status whether the message is read or not. true if it's read, otherwise false
Timestamp registdate Registered date
Timestamp expiredate Expire date

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.UPDATEMESSAGE

PLAYER.UPDATEMESSAGE( action, mode, messageNo, options, onComplete, onError )

pasdk.PLAYER.UPDATEMESSAGE('read', 'msg', 1, {}, function(){
    //onComplete
    console.log('success');
}, function(err) {
    //onError
    console.log(err);
});

PLAYER.UPDATEMESSAGE( action, mode, messageNo, options, onComplete, onError )

Check if user has new messages or not. It returns amount of new(unread) messages.

action argument

Type Description
String read to set a message as read.
delete to delete a message.

mode argument

Type Description
String noti for notification
msg for message
prize for prize

messageNo argument

Type Description
Number Notification, message, or prize unique number.

options argument

Type Description
Object Not used yet.

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.GETITEM

PLAYER.GETITEM( onComplete, onError )

pasdk.PLAYER.GETITEM(function(list){
    //onComplete
    console.log('success', list);       //see below
}, function (err) {
    //onError
    console.log('err', err);
});

item object

{
  "useritemno":"928",
  "title":"Iron Ball",
  "subtitle":"Destroy all kind of bircks",
  "itemimage":"https://ipascf.pocketarena.com/pa/iron-ball.png",
  "price":"100",
  "itemtype":"2",
  "itemstatus":"1",
  "itemlevel":"1",
  "itemexp":"0",
  "marketyn":"1",
  "productid":"bfLGiKLxJdwjwQ"
}

PLAYER.GETITEM(onComplete, onError)

Get player’s item list

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Array list List of item object. See below

item object

Type Key Description
String itemshopno Item shop number
String title Item title
String subtitle Item subtitle
String itemimage Item image url
String price Item price
String itemtype 1 : All mode (single and multi play)
2 : Single play
3 : Multi play
String itemstatus 1 : Not yet on market
2 : On market
String itemlevel Item level
String itemexp Item experience

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.UPDATEITEM

PLAYER.UPDATEITEM( items, onComplete, onError )

//'items' array should contains all 'item' objects from ITEM.GETGAMEITEM
var items = [{
             useritemno:"928",
             title:"Iron Ball",
             subtitle:"Destroy all kind of bircks",
             itemimage:"https://ipascf.pocketarena.com/pa/iron-ball.png",
             price:"100",
             itemtype:"2",
             itemstatus:"1",
             itemlevel:"1",
             itemexp:"0",
             marketyn:"1",
             productid:"bfLGiKLxJdwjwQ"
           }]

pasdk.PLAYER.UPDATEITEM( items, function(){
    //onComplete
    console.log('success');
}, function (err) {
    console.log('err', err);
});

PLAYER.UPDATEITEM( items, onComplete, onError )

Update player’s item list

items argument

Type Description
Array Array of containing item object.It should include not only items to update, but also the other items those player have. Item object is from ITEM.GETGAMEITEM

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.SENDVERIFICATIONEMAIL

PLAYER.SENDVERIFICATIONEMAIL( onComplete, onError )

pasdk.PLAYER.SENDVERIFICATIONEMAIL( function(){
    //onComplete
    console.log('success');
}, function (err) {
    console.log('err', err);
});

PLAYER.SENDVERIFICATIONEMAIL( onComplete, onError )

Send an email that contains verification link. This API is only for players who registered before Oct. 2018 and have not verified.

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

PLAYER.SIGNOUT

PLAYER.SIGNOUT( onComplete, onError )

pasdk.PLAYER.SIGNOUT( function( onComplete, onError ){
    //onComplete
    console.log('success');
}, function (err) {
    console.log('err', err);
});

PLAYER.SIGNOUT( onComplete, onError )

Remove user’s session data

Game API

GAME.START

GAME.START( onComplete, onError )

pasdk.GAME.START(function(){
    //onComplete
    console.log('success')
}, function (err) {
    //onError
    console.log('err', err)
})

GAME.START( onComplete, onError )

Call when a game start. This API must be called for every single play.

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

GAME.REPORTSCORE

GAME.REPORTSCORE( score, type, code, onComplete, onError )

var score = 22,
    type = 0,    //single play
    code = 1;   //win

pasdk.GAME.REPORTSCORE(score, type, code, function(rewardpoc){
    //onComplete
    console.log('rewardpoc', rewardpoc) //rewardpoc null | 14
}, function(err){
    //onError
    console.log('err', err)
})

GAME.REPORTSCORE(score, type, code, onComplete, onError)

Call when a game has finished to record the score to leaderboard. User’s sign in status can change after API call.

score argument

Type Description
Number Score to send

type argument

Type Value Description
Number 0 Single play
1 Multi play

code argument

Type Value Description
Number 0 Single
1 Win
2 Lose
3 Draw

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Number / Null rewardPOC Amount of POC as a reward. If this argument’s value is not null, either you can use UI.REWARD API or build your own UI using GETREWARDPOC

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

GAME.SETSAVEDATA

GAME.SETSAVEDATA( data1, data2, data3, data4, data5, onComplete, onError )

var data1 = '980;',
    data2 = '295;263;||263;262;',
    data3 = '',
    data4 = '4000',
    data5 = '3;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;'

pasdk.GAME.SETSAVEDATA(data1, data2, data3, data4, data5, function(){
    //onComplete
    console.log('success')
}, function(err){
    //onError
    console.log('err', err)
})

GAME.SETSAVEDATA( data1, data2, data3, data4, data5, onComplete, onError )

Set user game data

data1 ~ data5 arguments

Type Argument Description
String / Null data1 Any data. Send null if there is nothing to save.
String / Null data2 Any data. Send null if there is nothing to save.
String / Null data3 Any data. Send null if there is nothing to save.
String / Null data4 Any data. Send null if there is nothing to save.
String / Null data5 Any data. Send null if there is nothing to save.

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

GAME.GETSAVEDATA

GAME.GETSAVEDATA( onComplete, onError )

pasdk.GAME.GETSAVEDATA(function(data1, data2, data3, data4, data5){
    //onComplete
    console.log('data', data1, data2, data3, data4, data5)  //data '980;' '' '295;263;||263;262;' '4000' '3;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;'
}, function(err){
    //onError
    console.log('err', err)
})

GAME.GETSAVEDATA(onComplete, onError)

Get user game data

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
String data1 Any data. When it's empty, Empty string('') will be returned.
String data2 Any data. When it's empty, Empty string('') will be returned.
String data3 Any data. When it's empty, Empty string('') will be returned.
String data4 Any data. When it's empty, Empty string('') will be returned.
String data5 Any data. When it's empty, Empty string('') will be returned.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

GAME.LEADERBOARD

GAME.LEADERBOARD( refresh, onComplete, onError )

var refresh = true;

pasdk.GAME.LEADERBOARD(refresh, function(leaderboard){
    //onComplete
    console.log('leaderboard', leaderboard)     //see below 'leaderboard' object
}, function(err){
    //onError
    console.log('err', err) 
});

Value of leaderboard for normal mode

{  
   "eventtile":"",
   "startdate":1533254400,
   "enddate":1564790400,
   "myscore":"3",
   "myranking":"12",
   "leadertype":"0",
   "totalcount":21,
   "leader":{  
      "rowcount":21,
      "leaderdata":[  
         //see below 'entry' object
      ]
   }
}

Value of leaderboard for eSports mode

{  
   "eventtile":"",
   "startdate":1533254400,
   "enddate":1564790400,
   "gameid":"yVvIYCpw",
   "gameesportsno":"25",
   "gametitle":"Cricket Championship for MicroMax",
   "durationno": 2,
   "remaintime": 234550,
   "bgimage": "https:\/\/..com\/upload\/game\/pic\/1.png",
   "stageno": "20",
   "myleaderno": 24,
   "groupno": 1,
   "leadercount": 2,
   "leader":{
      "leaderdata":[  
         //see below 'entry' object
      ]
   },
   "rewards": [{
           "reward_en": {
               "title_1": "Final 10 users : $60   50 POC",
               "title_2": "TOP 3 of each Group :50 POC ",
               "description": "Final 10 users will be selected …...."
           },
           "reward_de": {
               "title_1": "Final 10 users : $60   50 POC",
               "title_2": "TOP 3 of each Group :50 POC ",
               "description": "Final 10 users will be selected …...."

           },
           "reward_zh": {
               "title_1": "Final 10 users : $60   50 POC",
               "title_2": "TOP 3 of each Group :50 POC ",
               "description": "Final 10 users will be selected …...."

           },
           "reward_ko": {
               "title_1": "Final 10 users : $60   50 POC",
               "title_2": "TOP 3 of each Group :50 POC ",
               "description": "Final 10 users will be selected …...."
           }
       }]
}

entry object. Values are the same in both mode.

[{  
    "ranking":"12",
    "isme":"1",
    "locale":"EN",
    "picture":"NrPtCkznLubJ.jpg",
    "nickname":"Spike Kang12",
    "gamescore":"3"
 }, {  
    "ranking":"14",
    "isme":"0",
    "locale":"VN",
    "picture":"",
    "nickname":"simon",
    "gamescore":"1"
}]

GAME.LEADERBOARD(refresh, onComplete, onError)

Get leaderboard data. Ordered by rank ascending

refresh argument

Type Description
Boolean true, get leaderboard data from server.
false, get leaderboard data from SDK local data.

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows. There are two ways the value returned.
Normal mode and eSports mode

leaderboard argument

  1. normal mode
Type Key Key Description
String myranking User's rank
Object leader Leaderboard data
Number rowcount Total number of entries
Array leaderdata Leaderboard list data. See entry object below
String type Leaderboard type. 0 : Win, 1 : Score
Number totalcount Total number of entries
  1. eSports mode
Type Key Key Description
String eventtitle Its value will be returned if event exists. Otherwise, empty string("")
String gameid Game id of current game
String gameesportsno Game id of current game
String gametitle Title of current eSports game
Number durationno
Number remaintime Remaining time of this duration. in seconds.
String bgimage Background image to decorate current game's status. Developers can use their own image.
String stageno Stage number for this duration.
Number myleaderno Number of my leaderboard.
Number groupno Group number of my leaderboard.
Number leadercount Total number of leaderboard entries.
Object leader This one has below properties.
Number rowcount Total number of leaderboard entries.
Array leaderdata Leaderboard list data. See entry object below
Array rewards list of reward object. See below reward object.

reward object

Type Key Key Description
Object reward_(language code, ex) en) This one has below properties.
String title_1 Title
String title_2 Title
String description Description

entry object

Both normal and eSports mode are the same.

Type Key Description
String ranking Entry user's ranking
String nickname Entry user's nickname
String gamescore Entry user's gamescore
String isme 0 : Not user, 1 : User
String locale Entry user's locale
String picture Entry user's profile image. '' for user who doesn't have profile image

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

Item API

ITEM.GETGAMEITEM

ITEM.GETGAMEITEM( onComplete, onError )

pasdk.ITEM.GETGAMEITEM(function(list){
    //onComplete
    console.log('list', list);   //see below
}, function (err) {
    //onError
    console.log('err', err);
});

item object

[{  
    "itemshopno":"1",
    "title":"Super Ball",
    "subtitle":"Destroy all kind of bircks",
    "itemimage":"https://ipascf.pocketarena.com/pa/superball.png",
    "price":"150",
    "itemtype":"2",
    "marketyn":"1",
    "productid":"OZUUEFKKjGHu"
}]

ITEM.GETGAMEITEM( onComplete, onError )

Get items that game offers to users

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

list argument

Type Description
Array List of item object

item object

Type Argument Description
String itemshopno Item shop number
String title Item title
String subtitle Item subtitle
String itemimage Item image url
String price Item price
String itemtype 1 : All mode
2 : single play
3 : multi play
String marketyn 1 : Using item in blockchain
2 : Not using item in blockchain
String productid Product ID from EmojiGames itemshop. Empty string('') when marketyn is 0

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

ITEM.CHECKDEFAULTITEMS

ITEM.CHECKDEFAULTITEMS( onComplete, onError )

pasdk.ITEM.CHECKDEFAULTITEMS(function(list){
    //onComplete
    console.log('list', list)       //see below
}, function(err){
    //onError
    console.log('err', err)
})

item object

[{  
    "useritemno":"928",
    "title":"Iron Ball",
    "subtitle":"Destroy all kind of bircks",
    "itemimage":"https://ipascf.pocketarena.com/pa/iron-ball.png",
    "price":"100",
    "itemtype":"2",
    "itemstatus":"1",
    "itemlevel":"1",
    "itemexp":"0",
    "marketyn":"1",
    "productid":"bfLGiKLxJdwjwQ"
}]

ITEM.CHECKDEFAULTITEMS( onComplete, onError )

Check if user is given default items. It not, it will be given.

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Array list List of item object. Same from PLAYER.GETITEM

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

ITEM.PURCHASE

ITEM.PURCHASE( items, onComplete, onError )

//list of 'item' object
var items = [{
    itemshopno:"1",
    title:"Super Ball",
    subtitle:"Destroy all kind of bircks",
    itemimage:"https://ipascf.pocketarena.com/pa/superball.png",
    price:"150",
    itemtype:"2",
    marketyn:"1",
    productid:"OZUUEFKKjGHu"
}];

pasdk.ITEM.PURCHASE(items, function(){
    //onComplete
    console.log('success');
}, function (err) {
    //onError
    console.log('err', err);
});

ITEM.PURCHASE( items, onComplete, onError )

Call when user purchases an item from ITEM.GETGAMEITEM API

items argument

Type Description
Array List of item object to send to server. Same item from ITEM.GETGAMEITEM API

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI API

Display UI on screen such as leaderboard, sign in/up and tokenshop. Please note that …
1. animation duration of modal open and closing is 400ms. This may close a modal that is called during the animation phase.
2. User’s sign in status can be changed after UI API call. For example, non signed in user can sign in/up when the modal is open, because some contents are required sign in/up and the UI will prompt the user to sign in/up modal.

UI.SIGNUP

UI.SIGNUP( onComplete, onError )

pasdk.UI.SIGNUP(function(player, poc){
    //onComplete
    console.log('success', player, poc)     //success {...} 87568
}, function (err) {
    //onError
    //ex) User clicked 'X'(close) button
    console.log('err', err)
})

UI.SIGNUP( onComplete, onError )

Display sign up modal

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Object player Player info. See PLAYER.GETINFO
Number / Null poc null if user has not done phone verification. Otherwise POC balance.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.SIGNIN

UI.SIGNIN( onComplete, onError )

pasdk.UI.SIGNIN(function(player, poc){
    //onComplete
    console.log('success', player, poc)     //success {...} 87568
}, function (err) {
    //onError
    //ex) User clicked 'X'(close) button
    console.log('err', err)
})

UI.SIGNIN( onComplete, onError )

Display sign in modal

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Object player Player info. See PLAYER.GETINFO
Number / Null poc null if user has not done phone verification. Otherwise POC balance.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.MYPROFILE

UI.MYPROFILE( onComplete, onError )

pasdk.UI.MYPROFILE(function(isSignedIn){
    //onSignout
    console.log('success')
}, function (err) {
    //onError
    //ex) User clicked 'X'(close) button
    console.log('err', err)
})

UI.MYPROFILE( onComplete, onError )

Display my profile modal. Please note that user can sign out and change profile info while using this UI.

onComplete argument

Type Description
Function Triggered when user clicks sign out button, and edit profile and closes it.
It returns below argument.

isSignedIn argument

Type Description
Boolean true if user kept the session. Otherwise, false

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.EDITPROFILE

UI.EDITPROFILE( onComplete, onError )

pasdk.UI.EDITPROFILE(function(){
    //onComplete
    console.log('success')
}, function (err) {
    //onError
    //ex) User clicked 'X'(close) button
    console.log('err', err)
})

UI.EDITPROFILE( onComplete, onError )

Display my profile edit form modal

onComplete argument

Type Description
Function Triggered when call is success.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.MESSAGEBOX

UI.MESSAGEBOX( onError )

pasdk.UI.MESSAGEBOX(function (err) {
    //onError
    //ex) User clicked 'X'(close) button
    console.log('err', err)
})

UI.MESSAGEBOX( onError )

Display my message box modal

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.REWARD

UI.REWARD( POCamount, onComplete, onError )

var pocAmount = 18;

pasdk.UI.REWARD( POCamount, function(POCamount, POCbalance, itemAmount){
    //onComplete
    console.log('success')
}, function (err) {
    //onError
    //ex) User clicked 'X'(close) button
    console.log('err', err)
})

UI.REWARD( POCamount, onComplete, onError )

Display POC reward modal. This API is for onComplete argument of GAME.REPORTSCORE

POCamount argument

Type Description
Number POC amount to receive. This value is from onComplete argument of GAME.REPORTSCORE

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Number POCamount Rewarded POC
Number / Null POCbalance Number is returned, when user purchased something from POC Shop. Otherwise, null. The balance doesn’t include POCamount.
Number / Null itemAmount Number is returned, when user purchased something from POC Shop. Otherwise, null. Item that user purchased by POC.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.LEADERBOARD

UI.LEADERBOARD( onError )

pasdk.UI.LEADERBOARD(function (err) {
    //onError
    //ex) User clicked 'X'(close) button
    console.log('err', err)
})

UI.LEADERBOARD( onError )

Display leaderboard modal

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.PATOKENSHOP

UI.PATOKENSHOP( onClose, onError )

pasdk.UI.PATOKENSHOP( function(POC, purchasedItem){
    //onClose
    //User clicked 'X'(close) button after purchase
    console.log('success', POC, purchasedItem)      //success 19 3
}, function (err) {
    //onError
    //ex) User clicked 'X'(close) button without purchase
    console.log('err', err)
})

UI.PATOKENSHOP(onClose, onError)

Display token shop modal. When purchase is made, SDK will calculate and return POC balance and the total amount of item to onClose argument.

onClose argument

Type Description
Function Triggered when user click ‘x’(close) button after purchasing item(s).

onClose returns belows.

Type Argument Description
String POC POC balance after purchase
Number purchsedItem Amount of items purchased in the modal

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.MESSAGE

UI.MESSAGE( message, onComplete, onError )

var message = {title : 'Hi there', 
        message: 'Welcome to Pocket Arena!<br>Want to join?',
        buttons: [
            { text : "Sure" },
            { text : "No, thanks" }     //up to two buttons
             ]};

pasdk.UI.MESSAGE( message, function(idx){
    //onComplete
    if ( idx == 0 ) {
        console.log('\'Sure\' button clicked ')
    }else if ( idx == 1 ) {
        console.log('\'No, thanks\' button clicked ')
    }

}, function (err) {
    //onError
    //ex) User clicked 'X'(close) button 
    console.log('err', err)
})

UI.MESSAGE( message, onComplete, onError )

Display a dialog that contains messages.

message argument

Type Description
object Setting for message dialog
Type Key Description
String title Modal title
String message Modal message
Array buttons Text for buttons. Up to two buttons. Contains button object

button object

Type Key Description
String text Button text

onComplete argument

Type Description
Function Triggered when user click OK button.

onError argument

Type Description
Function Triggered when error occurs.

See Errors menu

UI.CLOSE

UI.CLOSE()

pasdk.UI.CLOSE()

UI.CLOSE()

Close modal that is open currently

Errors

error object

{
  "returncode" : 400,
  "detail":"LACK_OF_POC",
  "message":"BAD REQUEST",
  "userMessage":"Insufficient amount of POC."
}
returncode message detail userMessage
200 Modal closed MODAL_CLOSED Modal closed.
400 Bad request
ex) When clients send like below - wrong parameters and/or its value, - missing required parameters
MISSING_PARAMETER
WRONG_PARAMS_VALUE Please check your request and try it again.
LACK_OF_POC Insufficient amount of POC.
EMAIL_IS_ALREADY_IN_USE An account with this email is already in use.
WRONG_SHOP_ITEM The item could not be found in the shop.
WRONG_ID_OR_PASSWORD Invalid ID or password.
INVALID_PHONE_NUMBER Phone number is invalid.
THIS_PHONE_NUMBER_IS_ALREADY_USED_TO_VERIFY This phone number is already in use.
WRONG_CURRENT_PASSWORD Current password is incorrect.
WRONG_FILE_EXTENSION Wrong file extension.
WRONG_USER_INFO_OR_OTP Could not sign in because of wrong user info.
NEED_AGREEMENT_PACOIN Phone number verification is required to use POC.
UNKNOWN_USER_ITEM It's an unknown user item.
UNAVAILABLE_USER_ITEM The item is unavailable.
WRONG_PASSWORD Invalid ID or password.
401 Unauthorized
Player needs to sign in.
ex) - Valid session time is over.
- Player signed out.
- Player is not signed in.
- disabled account
UNKNOWN_USER Unknown user.
DISABLED_ACCOUNT This account has been disabled.
SESSION_EXPIRED Session has expired.
402 Phone verification required
User needs to do email verification to use POC. When user is not verified by phone this code will be returned
PHONE_VERIFICATION_REQUIRED Phone verification required.
429 Too many request TOO_MANY_SIGN_UP_WITH_SAME_IP You can not create a PA Account on your current IP address.
500 Server error
ex) server is not available, unknown error, etc
SYSTEM_ERROR Server error has occurred.
CAN_NOT_GET_USER_POC Server error has occurred.
POC_SERVER_DID_NOT_RESPONSE Server error has occurred.
CAN_NOT_REGISTER_TO_BLOCKCHAIN Server error has occurred.
502 Bad gateway BAD_GATEWAY Server error has occurred.
503 Service unavailable : ex) timeout, connection lost SERVICE_UNAVAILABLE Service unavailable.
505 Unknown
Unknown error
UNKNOWN Unknown error has occurred.
Please try it later.
FAILED_TO_UPDATE_USER_DATA Save failed. Please try it again.
ETC
When message is delivered from another server. The message varies.
Format : “ETC : (a message from another server)”
ex) “ETC : error on loadAccount“