Players

DEPRECATED since 1.1.0

This feature is now deprecated, and you should use Profiles instead.

More details and API reference: Players

A player is defined as a profile on the mobile application. If your game server allows multiple characters for one player, then you can consider that one iPear player = one character on your server. Also iPear player = one character = one profile for websocket service, it uses a different name but are exactly the same.

Reference

KeyTypeDescription
customIdstring
unique
Unique identifier from your services (1-64 characters)
rpNamestringRolePlay name of the profile (1-64 characters)
rpNumberstring
unique
Phone number of the profile (1-64 characters)

Methods

.add

.add(customId, rpName, rpNumber)

DEPRECATED since 1.1.0

This feature is now deprecated, and you should use [Profiles] Create instead.

Adds a player to your iPear server data.

More details and API reference: Create player

Parameters

KeyTypeDescription
customIdstring
unique
required
Unique identifier from your services (1-64 characters)
rpNamestring
required
RolePlay name of the profile (1-64 characters)
rpNumberstring
unique
required
Phone number of the profile (1-64 characters)

Returns

Promise<{ customId: string, qrcode: string }>

Examples

Promise use

app.players.add("1234", "John Doe", "555-5126").then((player) => {
    console.log(player);
}).catch((error) => {
    console.log('An error has been occurred!', error);
})

Async use

try {
    const player = await app.players.add("1234", "John Doe", "555-5126");
    console.log(player);
} catch (error) {
    console.log('An error has been occurred!', error);
}

Result

{
  "customId": "1234",
  "qrcode": "https://link_to_qrcode.com/4586632.png"
}

.getQrCode

.getQrCode(customId)

DEPRECATED since 1.1.0

This feature is now deprecated, and you should use [Profiles] Retrieve QR Code instead.

Retrieve a new QR Code for a player profile.

Important

You need to add (/create) a player before trying to get a new QR Code.

More details and API reference: Retrieve QR Code

Parameters

KeyTypeDescription
customIdstring
unique
required
Unique identifier from your services (1-64 characters)

Returns

Promise<{ customId: string, qrcode: string }>

Examples

Promise use

app.players.getQrCode("1234").then((data) => {
    console.log(data);
}).catch((error) => {
    console.log('An error has been occurred!', error);
})

Async use

try {
    const data = await app.players.getQrCode("1234");
    console.log(data);
} catch (error) {
    console.log('An error has been occurred!', error);
}

Result

{
  "customId": "1234",
  "qrcode": "https://link_to_qrcode.com/544548.png"
}

.getSecretCode

.getSecretCode(customId)

DEPRECATED since 1.1.0

This feature is now deprecated, and you should use [Profiles] Retrieve Secret Code instead.

Retrieve a new secret code for a player profile. A secret allows the user to avoid scanning the QR Code. (useful in case that their camera doesn't work)

One code is available for 5 minutes.

Important

You need to add (/create) a player before trying to get a new secret code.

More details and API reference: Retrieve secret code

Parameters

KeyTypeDescription
customIdstring
unique
required
Unique identifier from your services (1-64 characters)

Returns

Promise<{ customId: string, code: string, expiresAt: number, expiresAt_date: Date }>

Examples

Promise use

app.players.getSecretCode("1234").then((data) => {
    console.log(data);
}).catch((error) => {
    console.log('An error has been occurred!', error);
})

Async use

try {
    const data = await app.players.getSecretCode("1234");
    console.log(data);
} catch (error) {
    console.log('An error has been occurred!', error);
}

Result

{
  "customId": "1234",
  "code": "486327",
  "expiresAt": 1682619471476,
  "expiresAt_date": Date(1682619471476)
}

.remove

.remove(customId)

Remove a player profile from your iPear server data.

More details and API reference: Delete player

Parameters

KeyTypeDescription
customIdstring
unique
required
Unique identifier from your services (1-64 characters)

Returns

Promise<boolean>

Examples

Promise use

app.players.remove("1234").then((deleted) => {
    console.log(deleted);
}).catch((error) => {
    console.log('An error has been occurred!', error);
})

Async use

try {
    const deleted = await app.players.remove("1234");
    console.log(deleted);
} catch (error) {
    console.log('An error has been occurred!', error);
}

Result

true

Powered by Doctave