<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Derya Özgün Yalçın</title>
    <description>The latest articles on Forem by Derya Özgün Yalçın (@dozgunyal).</description>
    <link>https://forem.com/dozgunyal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F19789%2F9dcadecb-d7df-4a46-9c7c-c2d912a395e4.jpeg</url>
      <title>Forem: Derya Özgün Yalçın</title>
      <link>https://forem.com/dozgunyal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dozgunyal"/>
    <language>en</language>
    <item>
      <title>Adding Facebook SDK to a React Native App for iOS</title>
      <dc:creator>Derya Özgün Yalçın</dc:creator>
      <pubDate>Sat, 20 Mar 2021 19:37:05 +0000</pubDate>
      <link>https://forem.com/dozgunyal/adding-facebook-sdk-to-a-react-native-app-for-ios-cno</link>
      <guid>https://forem.com/dozgunyal/adding-facebook-sdk-to-a-react-native-app-for-ios-cno</guid>
      <description>&lt;p&gt;Facebook announced that they ended support for Facebook SDK for React Native in this &lt;a href="https://developers.facebook.com/blog/post/2021/01/19/introducing-facebook-platform-sdk-version-9/"&gt;article&lt;/a&gt;. They claim that community is good enough to maintain this SDK. This version of &lt;a href="https://github.com/facebook/react-native-fbsdk/blob/b791efe311a47fd070d1348434c41e30db953ec2/README.md"&gt;README&lt;/a&gt; file of the repo says otherwise.&lt;/p&gt;

&lt;p&gt;Recently I have been experimenting with the SDK to use Login function for a game that I am creating using React Native. Yes, I admit that this is a weird combination but time will show if it's worth it.&lt;/p&gt;

&lt;p&gt;So, let's try to install Facebook SDK to the latest version of React Native. As of March 2021, this means: &lt;a href="https://github.com/facebook/react-native/releases"&gt;0.64.0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First Step&lt;/strong&gt;, the classic yarn add. The only step that is really up to date&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add react-native-fbsdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(add &lt;code&gt;-E&lt;/code&gt; if you want the exact/latest version).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second Step&lt;/strong&gt;, Link (Which is not relevant for latest version)&lt;br&gt;
For iOS, we need to install the pods. The example command given is valid but, not recommended. React Native now recommends using npx.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx pod-install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Third Step&lt;/strong&gt;, Configuration. The documentation starts with a link to a &lt;a href="https://developers.facebook.com/docs/ios/getting-started/?sdk=cocoapods"&gt;Facebook Documentation&lt;/a&gt; and asks you to do the 3. and 4. steps. This is only valid if you have already got a Facebook App configured. And giving Step numbers for this documentation is not a clever solution because that documentation has two Step 2's.&lt;/p&gt;

&lt;p&gt;For a Facebook App to be configured follow "Register and Configure Your App with Facebook" step of  &lt;a href="https://developers.facebook.com/docs/ios/getting-started/?sdk=cocoapods"&gt;Facebook Documentation&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a Developer Account&lt;/li&gt;
&lt;li&gt;Register your App&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now you can configure your &lt;code&gt;Info.plist&lt;/code&gt; as described in "Configure Your Project" section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;key&amp;gt;CFBundleURLTypes&amp;lt;/key&amp;gt;
&amp;lt;array&amp;gt;
  &amp;lt;dict&amp;gt;
  &amp;lt;key&amp;gt;CFBundleURLSchemes&amp;lt;/key&amp;gt;
  &amp;lt;array&amp;gt;
    &amp;lt;string&amp;gt;fb[APP_ID]&amp;lt;/string&amp;gt;
  &amp;lt;/array&amp;gt;
  &amp;lt;/dict&amp;gt;
&amp;lt;/array&amp;gt;
&amp;lt;key&amp;gt;FacebookAppID&amp;lt;/key&amp;gt;
&amp;lt;string&amp;gt;[APP_ID]&amp;lt;/string&amp;gt;
&amp;lt;key&amp;gt;FacebookDisplayName&amp;lt;/key&amp;gt;
&amp;lt;string&amp;gt;[APP_NAME]&amp;lt;/string&amp;gt;
&amp;lt;key&amp;gt;LSApplicationQueriesSchemes&amp;lt;/key&amp;gt;
&amp;lt;array&amp;gt;
  &amp;lt;string&amp;gt;fbapi&amp;lt;/string&amp;gt;
  &amp;lt;string&amp;gt;fbauth&amp;lt;/string&amp;gt;
  &amp;lt;string&amp;gt;fbauth2&amp;lt;/string&amp;gt;
  &amp;lt;string&amp;gt;fbshareextension&amp;lt;/string&amp;gt;
&amp;lt;/array&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Manage QueriesSchemes array as per your needs.&lt;/p&gt;

&lt;p&gt;Now, you need to connect the App Delegate. For this, &lt;code&gt;/ios/PROJECT/AppDelegate.m&lt;/code&gt; needs to be changed. Two changes are needed, &lt;code&gt;didFinishLaunchingWithOptions&lt;/code&gt; and &lt;code&gt;openUrl&lt;/code&gt;. But they made the explanation so vague that it is impossible to understand. In github issues section I found the best &lt;a href="https://github.com/facebook/react-native-fbsdk/issues/770#issuecomment-653032031"&gt;comment&lt;/a&gt; and it suggest to take a look at the &lt;a href="https://github.com/facebook/react-native-fbsdk/blob/master/example/ios/RNFBSDKExample/AppDelegate.m"&gt;example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the file these are done:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;#import &amp;lt;FBSDKCoreKit/FBSDKCoreKit.h&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Comment out or remove FlipperKit related code (this should be optional, not an expert move)&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];&lt;/code&gt; line to &lt;code&gt;didFinishLaunchingWithOptions&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;openURL&lt;/code&gt; to the end of file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now it seems like you are done, but, your builds will fail. You will see the troubleshoot part and notice that you need to add a &lt;code&gt;File.swift&lt;/code&gt; in your project folder. You will create the file but it will not work and you will need to search github issues again. You will come across this &lt;a href="https://github.com/facebook/react-native-fbsdk/issues/794#issuecomment-695217977"&gt;comment&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, the file should be created using Xcode. And when it ask if you if you want to "Create Bridging Header". Click on "yes/accept/please" button immediately.&lt;/p&gt;

&lt;p&gt;Now build and enjoy the Facebook SDK.&lt;/p&gt;

</description>
      <category>facebooksdk</category>
      <category>reactnative</category>
      <category>ios</category>
    </item>
    <item>
      <title>Hi, I'm Derya Ozgun Yalcin</title>
      <dc:creator>Derya Özgün Yalçın</dc:creator>
      <pubDate>Thu, 25 May 2017 13:14:16 +0000</pubDate>
      <link>https://forem.com/dozgunyal/hi-im-derya-zgn-yaln</link>
      <guid>https://forem.com/dozgunyal/hi-im-derya-zgn-yaln</guid>
      <description>&lt;p&gt;You can find me on GitHub as &lt;a href="https://github.com/dozgunyal" rel="noopener noreferrer"&gt;dozgunyal&lt;/a&gt;&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
