Skip to content

Commit 9f5111a

Browse files
Add new Poki User Account methods (#2096)
1 parent 7ad77b7 commit 9f5111a

1 file changed

Lines changed: 121 additions & 1 deletion

File tree

extensions/reviewed/PokiGamesSDKHtml.json

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "PokiGamesSDKHtml",
1010
"previewIconUrl": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1NzguODggMjczLjE2Ij4KCTxwYXRoIGZpbGw9ImJsYWNrIiBkPSJNNTQxIDg1LjhjMjEgMCAzOC0xNy40IDM4LTM4LjcgMC0yMC40LTE3LjQtMzcuNy0zOC0zNy43UzUwMy41IDI2LjYgNTAzLjUgNDdjMCAyMS40IDE3IDM4LjggMzcuNyAzOC44eiI+Cgk8L3BhdGg+Cgk8cGF0aCBmaWxsPSJibGFjayIgZD0iTTUwNCA5OS4zdjExMC41TDQ3MCAxMzZjMTUuNC0xOS4zIDIxLjctNDYuNCAyMi40LTY2VjU0aC02MC4ydjE1LjVjLTEgMTkuNi03LjMgMjguOC0yNC44IDM0LjVWMEgzNDZ2NDQuNEMzMjQgMjEuNiAyOTMgOS42IDI1Ni43IDkuNmMtNDAgMC03MyAxMy44LTk1LjYgNDBhMTE4IDExOCAwIDAgMC0xNyAyNi4yQzEyOSA2MC42IDEwOC40IDU0IDg0IDU0SDB2MjE5LjJoNTZWMjIxaDI4YzI0LjQgMCA0NS04LjMgNjAtMjMuN2ExMTYuMyAxMTYuMyAwIDAgMCAxNy42IDI3YzIyLjcgMjUuOCA1NS41IDM5LjMgOTUgMzkuMyAzOC42IDAgNzEtMTMuNSA5My42LTM5bDQuNS01LjZoNTIuN3YtNTQuM2w4LTIgMjYgNTYuNGgxMzYuOFY5OS40aC03NHptLTQxOCA2NEg1NnYtNTNoMjkuMmM3LjYgMCAyMC4zIDUuMiAyMC4zIDI1LjUgMCAxMy01LjQgMjcuMy0xOS40IDI3LjN6bTE3MCA2MGMtNDcuMyAwLTg1LjctMzkuNC04NS43LTg3LjhDMTcwLjMgODkgMjA5LjUgNTAgMjU2IDUwczg1LjYgMzkgODUuNiA4NS41YzAgNDguNC0zOC40IDg3LjgtODUuNiA4Ny44eiI+Cgk8L3BhdGg+Cgk8cGF0aCBmaWxsPSJibGFjayIgZD0iTTI1NiAxNDJjLTM4IDAtNTcgNi41LTY1IDguNiA2LjcgMzAuNSAzMy4yIDUzLjMgNjUgNTMuM3M1OC4zLTIzIDY1LTUzLjRjLTgtMi0yNy4yLTguNy02NS04Ljd6Ij4KCTwvcGF0aD4KPC9zdmc+Cg==",
1111
"shortDescription": "Poki Games SDK: display ads and manage game lifecycle for Poki hosting.",
12-
"version": "0.1.1",
12+
"version": "0.1.2",
1313
"description": "Please refer to [Poki's guide](https://sdk.poki.com/sdk-documentation.html) to know when to call the different actions.",
1414
"origin": {
1515
"identifier": "PokiGamesSDKHtml",
@@ -429,6 +429,126 @@
429429
],
430430
"objectGroups": []
431431
},
432+
{
433+
"async": true,
434+
"description": "Prompt the player to log in with Poki.",
435+
"fullName": "Login",
436+
"functionType": "Action",
437+
"name": "Login",
438+
"sentence": "Log the player in with Poki",
439+
"events": [
440+
{
441+
"type": "BuiltinCommonInstructions::JsCode",
442+
"inlineCode": [
443+
"if (typeof PokiSDK === \"undefined\") {",
444+
" eventsFunctionContext.task.resolve();",
445+
" return;",
446+
"}",
447+
"const logger = new gdjs.Logger(\"Poki games SDK HTML\");",
448+
"PokiSDK.login().catch((error) => {",
449+
" logger.log(`Login failed: ${error}`);",
450+
"}).finally(() => {",
451+
" eventsFunctionContext.task.resolve();",
452+
"});",
453+
""
454+
],
455+
"parameterObjects": "",
456+
"useStrict": true,
457+
"eventsSheetExpanded": false
458+
}
459+
],
460+
"parameters": [],
461+
"objectGroups": []
462+
},
463+
{
464+
"async": true,
465+
"description": "Get the current Poki user and store it in a structure variable.",
466+
"fullName": "Get user",
467+
"functionType": "Action",
468+
"name": "GetUser",
469+
"sentence": "Get Poki user and store it in _PARAM0_",
470+
"events": [
471+
{
472+
"type": "BuiltinCommonInstructions::JsCode",
473+
"inlineCode": [
474+
"if (typeof PokiSDK === \"undefined\") {",
475+
" eventsFunctionContext.task.resolve();",
476+
" return;",
477+
"}",
478+
"const logger = new gdjs.Logger(\"Poki games SDK HTML\");",
479+
"/** @type {gdjs.Variable} */",
480+
"const result = eventsFunctionContext.getArgument(\"Result\");",
481+
"result.fromJSObject({ username: \"\", avatarUrl: \"\" });",
482+
"PokiSDK.getUser().then((user) => {",
483+
" const safeUser = user && typeof user === \"object\" ? user : {};",
484+
" result.fromJSObject({",
485+
" username: typeof safeUser.username === \"string\" ? safeUser.username : \"\",",
486+
" avatarUrl: typeof safeUser.avatarUrl === \"string\" ? safeUser.avatarUrl : \"\",",
487+
" });",
488+
"}).catch((error) => {",
489+
" logger.log(`Failed to get user: ${error}`);",
490+
"}).finally(() => {",
491+
" eventsFunctionContext.task.resolve();",
492+
"});",
493+
""
494+
],
495+
"parameterObjects": "",
496+
"useStrict": true,
497+
"eventsSheetExpanded": false
498+
}
499+
],
500+
"parameters": [
501+
{
502+
"description": "Structure variable where the user will be stored",
503+
"longDescription": "The result structure contains `username` and `avatarUrl`.",
504+
"name": "Result",
505+
"type": "variable"
506+
}
507+
],
508+
"objectGroups": []
509+
},
510+
{
511+
"async": true,
512+
"description": "Get the current Poki token and store it in a variable.",
513+
"fullName": "Get token",
514+
"functionType": "Action",
515+
"name": "GetToken",
516+
"sentence": "Get Poki token and store it in _PARAM0_",
517+
"events": [
518+
{
519+
"type": "BuiltinCommonInstructions::JsCode",
520+
"inlineCode": [
521+
"if (typeof PokiSDK === \"undefined\") {",
522+
" eventsFunctionContext.task.resolve();",
523+
" return;",
524+
"}",
525+
"const logger = new gdjs.Logger(\"Poki games SDK HTML\");",
526+
"/** @type {gdjs.Variable} */",
527+
"const result = eventsFunctionContext.getArgument(\"Result\");",
528+
"result.setString(\"\");",
529+
"PokiSDK.getToken().then((token) => {",
530+
" result.setString(typeof token === \"string\" ? token : \"\");",
531+
"}).catch((error) => {",
532+
" logger.log(`Failed to get token: ${error}`);",
533+
"}).finally(() => {",
534+
" eventsFunctionContext.task.resolve();",
535+
"});",
536+
""
537+
],
538+
"parameterObjects": "",
539+
"useStrict": true,
540+
"eventsSheetExpanded": false
541+
}
542+
],
543+
"parameters": [
544+
{
545+
"description": "Variable where the token will be stored",
546+
"name": "Result",
547+
"type": "variable"
548+
}
549+
],
550+
"objectGroups": []
551+
},
432552
{
433553
"description": "Measure an event for analytics.",
434554
"fullName": "Measure event",

0 commit comments

Comments
 (0)