DrMoriarty / godot-facebook

Facebook module for Godot Game Engine (android and iOS)
MIT License
81 stars 22 forks source link

move facebook app_id out of the module to enable events auto logging #2

Closed ssemakin closed 3 years ago

ssemakin commented 5 years ago

I'm trying to have AutoLogAppEventsEnabled=true to log basic statistics such as installs, launches, session lengths, retention without doing this all manually. No matter what I've tried would not make it work until I got to change app_id to mine in the module resources android/res/values/strings.xml. So its current content is this:

<?xml version='1.0' encoding='UTF-8'?>
<resources>
    <string name="facebook_app_id">SOMEONES_APP_ID</string>
    <string name="fb_login_protocol_scheme">fbSOMEONES_APP_ID</string>
</resources>

where SOMEONES_APP_ID is actually a number, but just didn't want to share it here. After changing this number to my app_id, basic events auto logging started to work.

Is there a way to set this number without recompiling this Godot module and Android templates? Basically this also means, that for each app_id (if there's several like production or dev) one would need to have a dedicated android godot template.

I've tried removing this from the android manifest file:

<meta-data android:name="com.facebook.sdk.ApplicationId"
           android:value="@string/facebook_app_id" />

But then I get the following error on app startup and auto logging wouldn't work:

08-23 09:13:41.077 29237 29237 I FacebookInitProvider: Failed to auto initialize the Facebook SDK
08-23 09:13:41.077 29237 29237 I FacebookInitProvider: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
08-23 09:13:41.077 29237 29237 I FacebookInitProvider:  at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:294)
08-23 09:13:41.077 29237 29237 I FacebookInitProvider:  at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:250)

So I found then this line to change to set app_id from the godot script and init facebook manually:

<meta-data android:name="com.facebook.sdk.AutoInitEnabled"
           android:value="false"/>

But it doesn't seem to do anything and the there's still same exception "failed to auto init sdk".

Given that in Godot project you can set Android permissions which then get injected into the build, so I wonder if these tags from the strings.xml can be also somehow taken from the godot project settings.

Trying to make this work on Godot 3.1.1-stable branch.

ssemakin commented 5 years ago

I've just had a functioning iOS build with the Facebook SDK and compared to it, Android far easier, so I don't know any more how much of an issue this one is. Though I can probably see ways to automate iOS build without rebuilding Godot iOS templates.

DrMoriarty commented 3 years ago

Plugin updated and using now new plugin management system.