Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: initializeSDK deprecation #1731

Closed
chwo opened this issue Apr 29, 2021 · 5 comments
Closed

Question: initializeSDK deprecation #1731

chwo opened this issue Apr 29, 2021 · 5 comments

Comments

@chwo
Copy link

chwo commented Apr 29, 2021

The initializeSDK method was deprecated in the last release 9.2.0. See 813fa58

Summary: Moving towards more instance methods in ApplicationDelegate since most of the existing class methods already relied on the singleton shared.

"This method is called automatically from application:didFinishLaunchingWithOptions:. Please use that method instead. This one will be removed in a future release."

The deprecation message states that one should use application:didFinishLaunchingWithOptions: instead.

We have the use case that we do not initialize the Facebook SDK in UIApplicationDelegate.application:didFinishLaunchingWithOptions:. Instead we do it at a later time when the user has given its consent.

So when not in the UIApplicationDelegate life-cycle context it feels unintuitive to start the SDK with the FBSDKCoreKit.ApplicationDelegate.application:didFinishLaunchingWithOptions: method named after the UIApplicationDelegate life-cycle. Furthermore it requires to pass on the provided application and launchOptions to that later time.

What are your thoughts about this? Did you consider keeping the initializeSDK as an instance method?

@Inakitajes
Copy link

Any updates on this? I have the same use case....

@joesus
Copy link
Contributor

joesus commented Jul 1, 2021

What are your thoughts about this?

This was a difficult API decision. I agree with your assessment that, "it feels unintuitive to start the SDK with the method named after the UIApplicationDelegate life-cycle". I'll own this unpopular decision. I was trying to adhere to a principle of least disruption. Our docs advocate setting up the SDK using that method and I used that in the assumption that most people are using it over the initializeSDK method.

I realized that it would be more effort and kind of kludgy to use the didFinishLaunchingWithOptions: variant outside of the UIApplicationDelegate life-cycle context, but that it could be done by calling it with UIApplication.shared and an empty dictionary for the launch options.

Did you consider keeping the initializeSDK as an instance method?

Of course, but I felt it was important to simplify the SDK by having a single point of initialization. To your earlier point, the current API doesn't make sense outside of the UIApplicationDelegate life-cycle. At some point we'll need to (and want to) make changes to this API to account for use cases like yours. Having everyone use the same point of initialization will make this later change simpler to communicate and adopt, and safer since there will be one fewer vector for potential bugs.

@joesus
Copy link
Contributor

joesus commented Sep 13, 2021

Based on the feedback we decided to reintroduce the initialize method in 11.1.0, see: CHANGELOG.

It's important to note that there is no intentional support for extensions at this time. The SDK has been built over many years with the assumption that an instance of UIApplication will be available. There is no instant fix for these cases, see some examples by searching the repo -- https://github.com/facebook/facebook-ios-sdk/search?l=Objective-C&q=uiapplication.

I imagine we will want to move towards full support of extensions but this will take some time and deliberation to get right.

In any case can close this issue. Thanks for participating in the process!

@sanvean
Copy link

sanvean commented Dec 7, 2021

For anyone upgrading from an older version of the SDK to v11 or v12 needing to use this.

ApplicationDelegate.initializeSDK(nil)

is now

ApplicationDelegate.shared.initializeSDK()

@joesus would it be possible for someone to go through the iOS Facebook SDK Docs and update them to match recent versions of the SDK?

Pages like this one are really out of date at this point:
https://developers.facebook.com/docs/app-events/gdpr-compliance/#for-ios

@teejayhh
Copy link

teejayhh commented May 13, 2024

Pages like this one are really out of date at this point:

They are still outdated today in 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@teejayhh @joesus @sanvean @chwo @Inakitajes and others