added api, cleaned up status events
This commit is contained in:
parent
fcbce77168
commit
9acfbf8484
199
siwg/api/siwg.api
Normal file
199
siwg/api/siwg.api
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
- name: siwg
|
||||||
|
type: table
|
||||||
|
desc: Functions and constants for interacting with Google Services (SIWG) APIs
|
||||||
|
|
||||||
|
members:
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: is_supported
|
||||||
|
type: function
|
||||||
|
desc: Check if Google Services are available & ready on the device.
|
||||||
|
|
||||||
|
returns:
|
||||||
|
- name: is_supported
|
||||||
|
type: boolean
|
||||||
|
desc: Status of Google Services on the device.
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
```lua
|
||||||
|
if siwg then
|
||||||
|
local is_supported = siwg.is_supported()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: login
|
||||||
|
type: function
|
||||||
|
desc: Login to SIWG using a button.
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
Log in to SIWG using a button:
|
||||||
|
```lua
|
||||||
|
if siwg then
|
||||||
|
siwg.login()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: silent_login
|
||||||
|
type: function
|
||||||
|
desc: Silent login to SIWG.
|
||||||
|
|
||||||
|
This function is trying to retrieve the currently signed-in player’s account.
|
||||||
|
|
||||||
|
[icon:attention] By default login methods request `GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN`.
|
||||||
|
But if you use Disk, we have to request extra scope `Drive.SCOPE_APPFOLDER`.
|
||||||
|
Or if you use ID token, we have to request ID token with provided client_id.
|
||||||
|
If so it causes the first time silent sign-in to fail, except for users who
|
||||||
|
have already signed in successfully on a different device. Turn off SIWG
|
||||||
|
features you don't want to use in `game.project`.
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
```lua
|
||||||
|
function init(self)
|
||||||
|
if siwg then
|
||||||
|
siwg.silent_login()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: logout
|
||||||
|
type: function
|
||||||
|
desc: Logout from SIWG
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
```lua
|
||||||
|
if siwg then
|
||||||
|
siwg.logout()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: get_display_name
|
||||||
|
type: function
|
||||||
|
desc: Get the current SIWG player display name.
|
||||||
|
|
||||||
|
returns:
|
||||||
|
- name: name
|
||||||
|
type: string
|
||||||
|
desc: The player's display name.
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
```lua
|
||||||
|
if siwg then
|
||||||
|
local name = siwg.get_display_name()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: get_id
|
||||||
|
type: function
|
||||||
|
desc: Get the current SIWG player id.
|
||||||
|
|
||||||
|
returns:
|
||||||
|
- name: id
|
||||||
|
type: string
|
||||||
|
desc: The player ID.
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
```lua
|
||||||
|
if siwg then
|
||||||
|
local id = siwg.get_id()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: get_id_token
|
||||||
|
type: function
|
||||||
|
desc: Get the current SIWG player id token. Available only if "siwg.client_id" is configured in game.project
|
||||||
|
and "siwg.request_id_token = 1".
|
||||||
|
|
||||||
|
returns:
|
||||||
|
- name: id_token
|
||||||
|
type: string
|
||||||
|
desc: The player ID token.
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
```lua
|
||||||
|
if siwg then
|
||||||
|
local id_token = siwg.get_id_token()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: get_server_auth_code
|
||||||
|
type: function
|
||||||
|
desc: Returns a one-time server auth code to send to your web server which can be exchanged for access token
|
||||||
|
|
||||||
|
returns:
|
||||||
|
- name: server_auth_code
|
||||||
|
type: string
|
||||||
|
desc: The server auth code for logged in account.
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
```lua
|
||||||
|
if siwg then
|
||||||
|
local server_auth_code = siwg.get_server_auth_code()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: is_logged_in
|
||||||
|
type: function
|
||||||
|
desc: Check if a user is logged in currently.
|
||||||
|
|
||||||
|
returns:
|
||||||
|
- name: is_loggedin
|
||||||
|
type: boolean
|
||||||
|
desc: Current login state.
|
||||||
|
|
||||||
|
examples:
|
||||||
|
- desc: |-
|
||||||
|
```lua
|
||||||
|
if siwg then
|
||||||
|
local is_loggedin = siwg.is_logged_in()
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
#*****************************************************************************************************
|
||||||
|
|
||||||
|
- name: MSG_SIGN_IN
|
||||||
|
type: number
|
||||||
|
desc: The message type that SIWG sends when finishing the asynchronous operation
|
||||||
|
after calling `siwg.login()`
|
||||||
|
|
||||||
|
- name: MSG_SILENT_SIGN_IN
|
||||||
|
type: number
|
||||||
|
desc: The message type that SIWG sends when finishing the asynchronous operation
|
||||||
|
after calling `siwg.silent_login()`
|
||||||
|
|
||||||
|
- name: MSG_SIGN_OUT
|
||||||
|
type: number
|
||||||
|
desc: The message type that SIWG sends when finishing the asynchronous operation
|
||||||
|
after calling `siwg.logout()`
|
||||||
|
|
||||||
|
- name: STATUS_SUCCESS
|
||||||
|
type: number
|
||||||
|
desc: An operation success.
|
||||||
|
|
||||||
|
- name: STATUS_FAILED
|
||||||
|
type: number
|
||||||
|
desc: An operation failed. Check the error field in the massage table.
|
@ -44,11 +44,9 @@ public class SiwgJNI {
|
|||||||
private static final int MSG_SIGN_IN = 1;
|
private static final int MSG_SIGN_IN = 1;
|
||||||
private static final int MSG_SILENT_SIGN_IN = 2;
|
private static final int MSG_SILENT_SIGN_IN = 2;
|
||||||
private static final int MSG_SIGN_OUT = 3;
|
private static final int MSG_SIGN_OUT = 3;
|
||||||
private static final int MSG_GET_EVENTS = 11;
|
|
||||||
|
|
||||||
private static final int STATUS_SUCCESS = 1;
|
private static final int STATUS_SUCCESS = 1;
|
||||||
private static final int STATUS_FAILED = 2;
|
private static final int STATUS_FAILED = 2;
|
||||||
private static final int STATUS_CONFLICT = 4;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Global Properties
|
// Global Properties
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "siwg.h"
|
#include "siwg.h"
|
||||||
#include "siwg_jni.h"
|
#include "siwg_jni.h"
|
||||||
#include "private_siwg_callback.h"
|
#include "siwg_callback.h"
|
||||||
#include "com_aterve_siwg_SiwgJNI.h"
|
#include "com_aterve_siwg_SiwgJNI.h"
|
||||||
|
|
||||||
static bool luaL_checkbool(lua_State *L, int numArg)
|
static bool luaL_checkbool(lua_State *L, int numArg)
|
||||||
@ -265,7 +265,6 @@ static void LuaInit(lua_State* L)
|
|||||||
|
|
||||||
SETCONSTANT(STATUS_SUCCESS)
|
SETCONSTANT(STATUS_SUCCESS)
|
||||||
SETCONSTANT(STATUS_FAILED)
|
SETCONSTANT(STATUS_FAILED)
|
||||||
SETCONSTANT(STATUS_CONFLICT)
|
|
||||||
#undef SETCONSTANT
|
#undef SETCONSTANT
|
||||||
|
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
@ -13,5 +13,4 @@ enum STATUS
|
|||||||
{
|
{
|
||||||
STATUS_SUCCESS = 1,
|
STATUS_SUCCESS = 1,
|
||||||
STATUS_FAILED = 2,
|
STATUS_FAILED = 2,
|
||||||
STATUS_CONFLICT = 4,
|
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#if defined(DM_PLATFORM_IOS) || defined(DM_PLATFORM_ANDROID)
|
#if defined(DM_PLATFORM_IOS) || defined(DM_PLATFORM_ANDROID)
|
||||||
#include "private_siwg_callback.h"
|
#include "siwg_callback.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static SIWG_callback m_callback;
|
static SIWG_callback m_callback;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user