项目作者: kurtsev0103

项目描述 :
Plugin for authorization with Facebook for Godot Game Engine (iOS)
高级语言: Objective-C++
项目地址: git://github.com/kurtsev0103/godot-facebook-auth.git
创建时间: 2021-09-12T10:48:45Z
项目社区:https://github.com/kurtsev0103/godot-facebook-auth

开源协议:MIT License

下载


GodotFacebookAuth

Plugin for authorization with Facebook for Godot Game Engine (iOS)

  • Supports iOS deployment target >= 10.0
  • Supports Godot version >= 3.3
  • FacebookSDK 12.0.2
  • Supports simulator

Installation

  1. Download Plugin for your version of Godot, unzip and copy files to your Godot project’s res://ios/plugins/godot_facebook_auth directory.

  2. You can find and activate plugin by going to Project -> Export… -> iOS and in the Options tab, scrolling to the Plugins section.

    img

  3. After exporting, you must configure an Info.plist file with an XML snippet that contains data about your app.

    • Right-click Info.plist, and choose Open As ▸ Source Code.

      img

    • Copy and paste the following XML snippet into the body of your file ( \…\).

      img

    • XML snippet

  1. <key>CFBundleURLTypes</key>
  2. <array>
  3. <dict>
  4. <key>CFBundleURLSchemes</key>
  5. <array>
  6. <string>fbAPP-ID</string>
  7. </array>
  8. </dict>
  9. </array>
  10. <key>FacebookAppID</key>
  11. <string>APP-ID</string>
  12. <key>FacebookClientToken</key>
  13. <string>CLIENT-TOKEN</string>
  14. <key>FacebookDisplayName</key>
  15. <string>APP-NAME</string>
  16. <key>LSApplicationQueriesSchemes</key>
  17. <array>
  18. <string>fbapi</string>
  19. <string>fbauth</string>
  20. <string>fbauth2</string>
  21. </array>
  1. In <array><string> in the key [CFBundleURLSchemes], replace APP-ID with your App ID.
  2. In <string> in the key FacebookAppID, replace APP-ID with your App ID.
  3. In <string> in the key FacebookClientToken, replace CLIENT-TOKEN with the value found under Settings > Advanced > Client Token in your App Dashboard.
  4. In <string> in the key FacebookDisplayName, replace APP-NAME with the name of your app.

Description

  • Methods

    1. # Check the status of authentication
    2. credential() -> void
    3. # Sign in with facebook
    4. sign_in() -> void
    5. # Sign out with facebook
    6. sign_out() -> void
  • Signals

    1. credential(result: Dictionary)
    2. authorization(result: Dictionary)

Samples and Example Usage

  • Initialization
    ```gdscript
    var godot_facebook_auth: Object

func _ready():
if Engine.has_singleton(“GodotFacebookAuth”):
godot_facebook_auth = Engine.get_singleton(“GodotFacebookAuth”)
godot_facebook_auth.connect(“credential”, self, “_on_credential”)
godot_facebook_auth.connect(“authorization”, self, “_on_authorization”)

  1. - Checking credential status
  2. ```gdscript
  3. # 1. Call the method anywhere in the code
  4. godot_facebook_auth.credential()
  5. # 2. Wait for the answer in the method below
  6. func _on_credential(result: Dictionary):
  7. if result.has("error"):
  8. print(result.error)
  9. else:
  10. print(result.state)
  11. # "authorized" <- user ID is in good state
  12. # "not_found" <- user ID was not found
  13. # "revoked" <- user ID was revoked by the user
  • Sign In

    1. # 1. Call the method anywhere in the code
    2. godot_facebook_auth.sign_in()
    3. # 2. Wait for the answer in the method below
    4. func _on_authorization(result: Dictionary):
    5. if result.has("error"):
    6. print(result.error)
    7. else:
    8. # Required
    9. print(result.token)
    10. print(result.user_id)
    11. # Optional (can be empty)
    12. print(result.email)
    13. print(result.name)
  • Sign Out

    1. # Call the method anywhere in the code
    2. godot_facebook_auth.sign_out()

Build from Source

  • Just run scripts/build.sh -v 3.3.4 where -v is desired Godot version

    You will find the ready-to-use archive with the plugin in the bin directory.