Skip to content

Commit

Permalink
Merge pull request #1 from defold/dev-cleanup
Browse files Browse the repository at this point in the history
Cleaned up extension and simplified it a lot
  • Loading branch information
britzl committed Aug 25, 2020
2 parents 6c7f685 + d553fba commit 833e689
Show file tree
Hide file tree
Showing 15 changed files with 664 additions and 1,174 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
@@ -0,0 +1,3 @@
github: defold
patreon: Defold
custom: ['https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NBNBHTUW4GS4C']
19 changes: 19 additions & 0 deletions .github/workflows/trigger-site-rebuild.yml
@@ -0,0 +1,19 @@
name: Trigger site rebuild

on: [push]

jobs:
site-rebuild:
runs-on: ubuntu-latest

steps: [
{
name: 'Repository dispatch',
uses: defold/repository-dispatch@1.2.1,
with: {
repo: 'defold/defold.github.io',
token: '${{ secrets.SERVICES_GITHUB_TOKEN }}',
user: 'services@defold.se',
action: 'extension-siwa'
}
}]
7 changes: 3 additions & 4 deletions README.md
@@ -1,6 +1,5 @@
# Sign in with Apple
Native extension to support the Sign in with Apple feature in Defold.
# Sign in with Apple extension for Defold

"Sign in with Apple makes it easy for users to sign in to your apps and websites using their Apple ID. Instead of filling out forms, verifying email addresses, and choosing new passwords, they can use Sign in with Apple to set up an account and start using your app right away. All accounts are protected with two-factor authentication for superior security, and Apple will not track users’ activity in your app or website" [Apple Developer docs](https://developer.apple.com/sign-in-with-apple/)
Defold [native extension](https://www.defold.com/manuals/extensions/) which provides access to Sign in with Apple functionality on iOS.

"Apps that use a third-party or social login service (such as Facebook Login, Google Sign-In, Sign in with Twitter, Sign In with LinkedIn, Login with Amazon, or WeChat Login) to set up or authenticate the user’s primary account with the app must also offer Sign in with Apple as an equivalent option. A user’s primary account is the account they establish with your app for the purposes of identifying themselves, signing in, and accessing your features and associated services." [Apple review guidelines](https://developer.apple.com/app-store/review/guidelines/#sign-in-with-apple)
[Manual, API and setup instructions](https://www.defold.com/extension-siwa/) is available on the official Defold site.
29 changes: 29 additions & 0 deletions docs/index.md
@@ -0,0 +1,29 @@
---
title: Sign in with Apple extension for Defold
brief: This manual covers how to setup and use Sign in with Apple in Defold.
---

# Sign in with Apple extension for Defold

This extension provides functions to use [Sign in with Apple](https://developer.apple.com/sign-in-with-apple/) to allow users to set up an account and sign in to your game with their Apple ID.

## Installation

To use this library in your Defold project, add the following URL to your `game.project` dependencies:

https://github.com/defold/extension-siwa/archive/master.zip

We recommend using a link to a zip file of a [specific release](https://github.com/defold/extension-siwa/releases).


## Setting up your app for Sign in with Apple

To get started you need to enable your app’s App ID with the Sign in with Apple capability. [Follow the official Apple developer instructions](https://help.apple.com/developer-account/?lang=en#/devde676e696) to get started.


## Source code

The source code is available on [GitHub](https://github.com/defold/extension-siwa)


## API reference
4 changes: 2 additions & 2 deletions game.project
Expand Up @@ -13,8 +13,8 @@ main_collection = /main/main.collectionc

[display]
width = 640
height = 480
height = 1136

[ios]
bundle_identifier = com.defold.siwa
bundle_identifier = com.defold.extension.siwa

179 changes: 62 additions & 117 deletions main/main.gui
Expand Up @@ -9,123 +9,6 @@ background_color {
z: 0.0
w: 0.0
}
nodes {
position {
x: 320.0
y: 239.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 640.0
y: 480.0
z: 0.0
w: 1.0
}
color {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "box"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 3.0
y: 2.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Hello World, I\'m SIWA"
font: "system_font"
id: "test_text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "box"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
shadow_alpha: 1.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 114.0
Expand Down Expand Up @@ -601,6 +484,68 @@ nodes {
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 20.0
y: 899.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 600.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Hello World, I\'m SIWA"
font: "system_font"
id: "test_text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NW
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
shadow_alpha: 1.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT
max_nodes: 512
38 changes: 20 additions & 18 deletions main/main.gui_script
@@ -1,38 +1,36 @@
local dl = require("dirtylarry.dirtylarry")

local good_id = "001869.37272b1d2d6e454d8b396e521ba4fc12.1006"
local bad_id = "abc123"

local lines = {}
local function log(msg, ...)
msg = msg:format(...)
print(msg)
gui.set_text(gui.get_node("test_text"), msg)

table.insert(lines, 1, msg)
table.remove(lines, 10)
gui.set_text(gui.get_node("test_text"), table.concat(lines, "\n"))
end

local function check_credentials_status(self, id)
log("check_credentials_status %s", id)
siwa.check_credentials_status(id, function(self, data)
log("result: %s", data.result)
for k, v in pairs(data) do
pprint(k)
pprint(v)
local function get_credential_state(self, id)
log("get_credential_state %s", id)
siwa.get_credential_state(id, function(self, data)
for k,v in pairs(data) do
log("%s: %s", k, tostring(v))
end
end)
end

local function authenticate(self)
log("authenticate")
siwa.authenticate(function(self, data)
log("result: %s", data.result)
for k, v in pairs(data) do
print(k)
pprint(v)
self.user_id = data.user_id
for k,v in pairs(data) do
log("%s: %s", k, tostring(v))
end
end)
end

local function is_siwa_supported()
return siwa and siwa.is_siwa_supported()
return siwa and siwa.is_supported()
end

function init(self)
Expand All @@ -48,11 +46,15 @@ end
function on_input(self, action_id, action)
if is_siwa_supported() then
dl:button("check", action_id, action, function()
check_credentials_status(self, good_id)
if self.user_id then
get_credential_state(self, self.user_id)
else
log("No user id. Login first")
end
end)

dl:button("check_fail", action_id, action, function()
check_credentials_status(self, bad_id)
check_credentials_status(self, "foobar")
end)

dl:button("login", action_id, action, function()
Expand Down

0 comments on commit 833e689

Please sign in to comment.