NAV Navbar

PA SDK Guide

latest version: v2.1

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 below onComplete function is triggered, you can just call any API.

Common API

new EmojigaGamesPASDK

new EmojigaGamesPASDK( options )

var options = {
    gameId : 'xxxxx',
    recaptcha : {
        siteKey : 'xxxxxxxx',
        verifyUrl : 'http://.....'
    }
}
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 Key Default Description
String gameId - Game ID
Object recaptcha - ReCaptcha info
String siteKey - ReCaptcha site key
String verifyUrl - Site URL to verify reCaptcha

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 occured.

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 : 'mbiz.spike@emojigames.io', password : '12341234'}, 
    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)
})

SIGNIN( type, params, onComplete, onError )

User sign in

type argument

Sign in type

Type Value Description
String email for email sign in
sns for SNS account sign in (Google, Facebook)

params argument

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

For email type

Key Type Description
email String email address
password String password. up to 8 characters

For sns type

Key Type Value Description
snsName String facebook
google

onComplete argument

Type Description
Function Triggered when call is success.
Argument Type Description
player object Player data. See PLAYER.GETINFO
poc number/null POC balance, null if user didn’t do phone verification

onError argument

Type Description
Function Triggered when error occured.

See Errors menu

SIGNUP

SIGNUP( type, params, onComplete, onError )

email type

pasdk.SIGNUP('email', {email : 'mbiz.spike@emojigames.io', password : '12341234'}, 
    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)
})

SIGNUP(type, params, onComplete, onError)

User sign up.

type argument

Sign up type

Type Value Description
String email for email sign in
sns for SNS account sign in (Google, Facebook)

params argument

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

For email type

Key Type Description
email String email address
password String password. up to 8 characters

For sns type

Key Type Value Description
snsName String facebook
google

onComplete argument

Type Description
Function Triggered when call is success.
Argument Type Description
player object Player data. See PLAYER.GETINFO
poc number/null POC balance, null if user didn’t do phone verification

onError argument

Type Description
Function Triggered when error occured.

See Errors menu

RESETPASSWORD

RESETPASSWORD( email, onComplete, onError )

pasdk.RESETPASSWORD ( 'mbiz.spike@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 occured.

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 occured.

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
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 occured.

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 POC that user will gain when current exp reaches next level. (ex : x18). /n Returns null, If user has not done phone verification.
Type Description
Function Triggered when error occured.

onError argument

Type Description
Function Triggered when error occured.

See Errors menu

GETREWARDPOC

GETREWARDPOC( params, onComplete, onError )

pasdk.GETREWARDPOC({token: 'xxxxxx'}, 
    function(poc){
        //onComplete
        console.log(poc)    //17
    }, 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. Also, Google reCaptcha verification is required. For that, you need a server API to verify the token. SDK will use reCaptcha info given at constructor API to verify server side. Developers need to implement how to get verified token, unless using UI.REWARD. For more information about reCaptcha please refer to its official documentation. Instead of this API, you can use UI.REWARD, it will take care of this process.

params argument

Type Description
Object Object for parameters to send to server verifying Google reCaptcha a verified token. token key is required. Also, additional parameters can be added. It depends on the server API’s need.
Type Key Description
String token Google reCaptcha verified token

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 occured.

See Errors menu

OPENLINK( pageName )

wallet

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

emojigames

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

OPENLINK(pageName)

Open PA Wallet or EmojiGames website page.

pageName argument

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

Account API

PLAYER.GETINFO

PLAYER.GETINFO()

pasdk.PLAYER.GETINFO()    //see below

player parameter

{
    "country":"Canada",
    "countryCode":"CA",
    "email":"mbiz.spike@emojigames.io",
    "idType":"email",
    "image":"https://pacoin.pocketarena.com/upload/user/image/NrPtCkznLubJ.jpg",
    "isVerified":true,
    "level":5,
    "nickname":"Spike Kang12",
    "rewardExp":{
        "POC":18,
        "exp":87
    }
}

PLAYER.GETINFO()

Get player’s information such as email, name, and so on.

Return value

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

player object

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
String image Player profile image
Boolean isVerified true if user finished phone 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

onError argument

Type Description
Function Triggered when error occured.

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. User's country code

currentPassword argument

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

newPassword argument

Type Description
String New password that user 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 occured.

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 occured.

See Errors menu

PLAYER.GETMYPOC

PLAYER.GETMYPOC( onComplete, onError )

pasdk.PLAYER.GETMYPOC(function(poc){
    //onComplete
    console.log('res', poc) //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 poc POC balance user currently has. Returns null, if user has not done phone verification.

onError argument

Type Description
Function Triggered when error occured.

See Errors menu

PLAYER.GETMESSAGE

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

pasdk.PLAYER.GETMESSAGE(null, null, function(limit, pagebalance, hasNext){
    //onComplete
    console.log('success', limit, pagebalance, hasNext);
}, function (err) {
    //onError
    console.log('err', err);
});

notification object

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

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

Get messages for user

limit argument

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

page argument

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

onComplete argument

Type Description
Function Triggered when call is success.

onComplete returns belows.

Type Argument Description
Number currentPage Current page number
Array list List of notifications. See notification object below.
Boolean hasNext true there are more pages. false there is no more pages.

notification object

Type Key Description
String notificationno Notification number. Unique.
String title Title
String description Description
String notificationtype Notification type. 1 : system notice, 2 : title
String\Null pocamount POC amount
Timestamp registdate Registered date

onError argument

Type Description
Function Triggered when error occured.

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 user’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 occured.

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 user’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 user 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 occured.

See Errors menu

PLAYER.SIGNOUT

PLAYER.SIGNOUT()

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 occured.

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

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 occured.

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 occured.

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 occured.

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

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

entry object

[{  
    "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.

leaderboard argument

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

entry object

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 occured.

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 occured.

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 occured.

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 occured.

See Errors menu

UI API

Display UI such as leaderboard, sign in/up so on on screen

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 occured.

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 occured.

See Errors menu

UI.MYPROFILE

UI.MYPROFILE( onSignOut, onError )

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

UI.MYPROFILE( onSignOut, onError )

Display my profile modal

onSignOut argument

Type Description
Function Triggered when user clicks sign out button.

onError argument

Type Description
Function Triggered when error occured.

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 occured.

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 occured.

See Errors menu

UI.REWARD

UI.REWARD( POCamount, onComplete, onError )

var pocAmount = 18;

pasdk.UI.REWARD( pocAmount, function(){
    //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 Reward POC after reCaptcha verification

onError argument

Type Description
Function Triggered when error occured.

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 occured.

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 occured.

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 occured.

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.
FAILED_TO_PASS_RECAPTCHA Failed to pass the reCAPTCHA, please try again.
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“