facebook / facebook-android-sdk

Used to integrate Android apps with Facebook Platform.
https://developers.facebook.com/docs/android
Other
6.07k stars 3.64k forks source link

The call FacebookSdk.setAutoInitEnabled(true) don't start initialization process #1199

Open vokruttabtale opened 10 months ago

vokruttabtale commented 10 months ago

Checklist before submitting a bug report

Java version

1.8.0.291

Android version

API 28, Android 9

Android SDK version

16.1.3

Installation platform & version

Gradle

Package

Core & AppEvents

Goals

Init facebook SDK manually

Expected results

Facebook SDK should be initialized

Actual results

Facebook skip initialization because of the method initializeIfNotInitialized() in UserSettingsManager class. Looks like the first condition should be the opposite. Now we return from this method when Facebook is not initialized.

private fun initializeIfNotInitialized() {
if (!FacebookSdk.isInitialized()) {
      return
    }
    if (!isInitialized.compareAndSet(false, true)) {
      return
    }
    userSettingPref =
        FacebookSdk.getApplicationContext()
            .getSharedPreferences(USER_SETTINGS, Context.MODE_PRIVATE)
    initializeUserSetting(autoLogAppEventsEnabled, advertiserIDCollectionEnabled, autoInitEnabled)
    initializeCodelessSetupEnabledAsync()
    logWarnings()
    logIfSDKSettingsChanged()
  }

Steps to reproduce

  1. Run the app

Code samples & details

// INSERT YOUR CODE HERE