Alfie Kemp

Alfie Kemp

1591311900

A Facebook Account Kit SDK wrapper for React Native

React Native Facebook Account Kit

A Facebook Account Kit SDK wrapper for react-native.

IMPORTANT: Deprecation Notice

As announced by Facebook the Account Kit is being deprecated meaning that this library will no longer be maintained

Supported versions - React Native / Facebook Account Kit

The table below shows the supported versions of React Native and the different versions of react-native-facebook-account-kit.

RN Facebook Account Kit 0.4.x 0.6.x 0.10.x 1.x.x 2.x.x
React Native 0.24 <0.48 0.48-56 >=0.57.x >=0.60.x

Installation

yarn add react-native-facebook-account-kit
cd ios && pod install && cd ..

For RN < 0.60.x Follow the installation steps described in this document

For RN < 0.40.0 Check the Troubleshooting Guide

Linking

Not necessary Check out the RN 0.60 release blog post

Configuration

Obtaining secret and token to configure the library

First of all you must obtain an Account App Id and an Account Kit Client Token. To obtain them you must create a Facebook application using facebook developer’s website.

In the part 1 of the following blog post series you will find detailed steps about how to create and configura a Facebook Account Kit application:

IOS Configuration

Add your Account App Id and an Account Kit Client Token to your project’s Info.plist file

<plist version="1.0">
  <dict>
    ...
    <key>FacebookAppID</key>
    <string>{YOUR_FACEBOOK_APP_ID}</string>
    <key>AccountKitClientToken</key>
    <string>{YOUR_ACCOUNT_KIT_CLIENT_TOKEN}</string>
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>ak{YOUR_FACEBOOK_APP_ID}</string>
        </array>
      </dict>
    </array>
    ...
  </dict>
</plist>

Android Configuration

Add your Account App Id and the Account Kit Client Token to the android/app/src/main/res/values/strings.xml:

...
<string name="fb_app_id">YOUR_FACEBOOK_APP_ID</string>
<string name="ak_client_token">YOUR_ACCOUNT_KIT_CLIENT_TOKEN</string>

Then update set your app metadata by editing the android/app/src/main/AndroidManifest.xml file:

...
<application>
    ...
    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/fb_app_id" />
    <meta-data
        android:name="com.facebook.accountkit.ApplicationName"
        android:value="@string/app_name" />
    <meta-data
        android:name="com.facebook.accountkit.ClientToken"
        android:value="@string/ak_client_token" />
    ...
</application>
...
  1. If you want AccountKit to prefill your phone number add the READ_PHONE_STATE permission to the android/app/src/main/AndroidManifest.xml file:
...
<manifest ...>
  ...
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  ...
</manifest>  
  1. (Optional) Exclude backup for Access Tokens on Android >= 6.0

    As per this documentation, Account Kit does not support automated backup (introduced in Android 6.0). The following steps will exclude automated backup

    1. Create a file android/app/src/main/res/xml/backup_config.xml that contains the follwoing:
    <?xml version="1.0" encoding="utf-8"?>
    <full-backup-content>
      <exclude domain="sharedpref" path="com.facebook.accountkit.AccessTokenManager.SharedPreferences.xml"/>
    </full-backup-content>
    
    1. In your AndroidManifest.xml add the following to exclude backup of Account Kit’s Access Token.
    <application
      //other configurations here
      android:fullBackupContent="@xml/backup_config" // add this line
    >
    

Usage

If you have issues with the method signatures you may be using an older version. Check the Releases Notes for breaking changes

import RNAccountKit from 'react-native-facebook-account-kit'

// Configures the SDK with some options
RNAccountKit.configure({
  responseType: 'token'|'code', // 'token' by default,
  titleType: 'login',
  initialAuthState: '',
  initialEmail: 'some.initial@email.com',
  initialPhoneCountryPrefix: '+1', // autodetected if none is provided
  initialPhoneNumber: '123-456-7890',
  facebookNotificationsEnabled: true|false, // true by default
  readPhoneStateEnabled: true|false, // true by default,
  countryWhitelist: ['AR'], // [] by default
  countryBlacklist: ['US'], // [] by default
  defaultCountry: 'AR',
  theme: {
    // for iOS only, see the Theme section
  },
  viewControllerMode: 'show'|'present', // for iOS only, 'present' by default
  getACallEnabled: true|false,
  setEnableInitialSmsButton: true|false, // true by default
})

// Shows the Facebook Account Kit view for login via SMS
RNAccountKit.loginWithPhone()
  .then((token) => {
    if (!token) {
      console.log('Login cancelled')
    } else {
      console.log(`Logged with phone. Token: ${token}`)
    }
  })

// Shows the Facebook Account Kit view for login via email
RNAccountKit.loginWithEmail()
  .then((token) => {
    if (!token) {
      console.log('Login cancelled')
    } else {
      console.log(`Logged with email. Token: ${token}`)
    }
  })

// Logouts the user, so getCurrentAccessToken() will retrieve null
RNAccountKit.logout()
  .then(() => {
    console.log('Logged out')
  })

// Retrieves the logged user access token, if any user is logged
RNAccountKit.getCurrentAccessToken()
  .then((token) => {
    console.log(`Current access token: ${token}`)
  })

// Retrieves the logged user account info, if any user is logged
RNAccountKit.getCurrentAccount()
  .then((account) => {
    console.log(`Current account: ${account}`)
  })

@MahbbRah put together a video tutorial of how to integrate the library you might find useful.

Examples

Try the examples. They are related to different React Native versions.

git clone https://github.com/underscopeio/react-native-facebook-account-kit
cd react-native-facebook-account-kit/examples/RN0XX
yarn
react-native run-ios
react-native run-android

Themes

iOS

import RNAccountKit, {
  Color,
  StatusBarStyle,
} from 'react-native-facebook-account-kit'

RNAccountKit.configure({
  ...,
  theme: {
    // Background
    backgroundColor: Color.rgba(0, 120, 0, 0.1),
    backgroundImage: 'background.png',
    // Button
    buttonBackgroundColor: Color.rgba(0, 153, 0, 1.0),
    buttonBorderColor: Color.rgba(0, 255, 0, 1),
    buttonTextColor: Color.rgba(0, 255, 0, 1),
    // Button disabled
    buttonDisabledBackgroundColor: Color.rgba(100, 153, 0, 0.5),
    buttonDisabledBorderColor: Color.rgba(100, 153, 0, 0.5),
    buttonDisabledTextColor: Color.rgba(100, 153, 0, 0.5),
    // Header
    headerBackgroundColor: Color.rgba(0, 153, 0, 1.0),
    headerButtonTextColor: Color.rgba(0, 153, 0, 0.5),
    headerTextColor: Color.rgba(0, 255, 0, 1),
    // Input
    inputBackgroundColor: Color.rgba(0, 255, 0, 1),
    inputBorderColor: Color.hex('#ccc'),
    inputTextColor: Color.hex('#0f0'),
    // Others
    iconColor: Color.rgba(0, 255, 0, 1),
    textColor: Color.hex('#0f0'),
    titleColor: Color.hex('#0f0'),
    // Header
    statusBarStyle: StatusBarStyle.LightContent, // or StatusBarStyle.Default
  }
})

To see the statusBarStyle reflected you must set the UIViewControllerBasedStatusBarAppearance property to true on your app’s Info.plist file. You can do it from XCode screen shot 2016-08-02 at 11 44 07 am

Android

Check this commit to see how it’s done in our sample app

  1. In your application styles.xml file (usually located in android/app/src/main/res/values folder) create a Theme with the following schema
<style name="LoginThemeYellow" parent="Theme.AccountKit">
    <item name="com_accountkit_primary_color">#f4bf56</item>
    <item name="com_accountkit_primary_text_color">@android:color/white</item>
    <item name="com_accountkit_secondary_text_color">#44566b</item>
    <item name="com_accountkit_status_bar_color">#ed9d00</item>

    <item name="com_accountkit_input_accent_color">?attr/com_accountkit_primary_color</item>
    <item name="com_accountkit_input_border_color">?attr/com_accountkit_primary_color</item>
</style>

See the full set of customizable fields here

  1. In your app AndroidManifest.xml file (usually under android/app/src/main folder) set that Theme to the AccountKitActivity
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" <-- Add this line
    ...>

    <!-- Set the AccountKitActivity theme -->
    <activity
      tools:replace="android:theme"
      android:name="com.facebook.accountkit.ui.AccountKitActivity"
      android:theme="@style/LoginThemeYellow" />

</manifest>

Troubleshooting

Missing android.support.v4.content

error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;

This is because of the breaking change introduced in react-native 0.60.0 and therefore in our 2.0.0.

In order to fix the issue you should either upgrade to react-native 0.60.0 of use the 1.2.0 of this library

Issue: #196

I have problems running the example

If you have trouble running any example try the following:

  1. Move the example out of the repo

  2. Remove this package local dependency from package.json

    -    "react-native-facebook-account-kit": "file:../.."
    
  3. Run yarn add react-native-facebook-account-kit

  4. Re-run react-native run-android or react-native run-ios

A system issue occured, Please try again" when sending SMS

  1. Check your FacebookAppID and AccountKitClientToken on iOS Info.plist and Android strings.xml are correct

  2. If you have enabled the client access token flow in fb account kit dashboard, then responseType should be set to code when calling configure

// Configures the SDK with some options
RNAccountKit.configure({
    responseType: 'code'
    ...
})

Issue: #68

iOS only: Login screen doesn’t show up

In some cases, if you implement the Login button in a presented Modal screen, you need to add viewControllerMode: 'show' into the configuration.

// Configures the SDK with some options
RNAccountKit.configure({
    viewControllerMode: 'show'
    ...
})

Issue: #167

I cannot integrate the library with RN versions < 0.40.0

Modify the android/build.gradle file to override the com.facebook.android:account-kit-sdk library with com.facebook.android:account-kit-sdk:4.15.0 and the compileSdkVersion and buildToolsVersion as depicted below

subprojects { subproject ->
    afterEvaluate{
        dependencies {
            compile ('com.facebook.android:account-kit-sdk:4.15.0'){
                force = true
                exclude group: 'com.parse.bolts', module: 'bolts-android';
                exclude group: 'com.parse.bolts', module: 'bolts-applinks';
                exclude group: 'com.parse.bolts', module: 'bolts-tasks';
            }
        }

        if(subproject.name == 'react-native-facebook-account-kit') {
            android {
                compileSdkVersion 23
                buildToolsVersion "23.0.3"
            }
        }
    }
}

Download Details:

Author: underscopeio

GitHub: https://github.com/underscopeio/react-native-facebook-account-kit

#react-native #react #mobile-apps

What is GEEK

Buddha Community

A Facebook Account Kit SDK wrapper for React Native
Autumn  Blick

Autumn Blick

1598839687

How native is React Native? | React Native vs Native App Development

If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?

In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.

A brief introduction to React Native

Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.

React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.

Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.

Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.

The popularity of React Native comes from its advantages. Some of its advantages are as follows:

  • Performance: It delivers optimal performance.
  • Cross-platform development: You can develop both Android and iOS apps with it. The reuse of code expedites development and reduces costs.
  • UI design: React Native enables you to design simple and responsive UI for your mobile app.
  • 3rd party plugins: This framework supports 3rd party plugins.
  • Developer community: A vibrant community of developers support React Native.

Why React Native is fundamentally different from earlier hybrid frameworks

Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.

React Native is very close to native. Consider the following aspects as described on the React Native website:

  • Access to many native platforms features: The primitives of React Native render to native platform UI. This means that your React Native app will use many native platform APIs as native apps would do.
  • Near-native user experience: React Native provides several native components, and these are platform agnostic.
  • The ease of accessing native APIs: React Native uses a declarative UI paradigm. This enables React Native to interact easily with native platform APIs since React Native wraps existing native code.

Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.

#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native

Hire Dedicated React Native Developer

Have you ever thought of having your own app that runs smoothly over multiple platforms?

React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. Hire Dedicated React Native Developer from top React Native development company, HourlyDeveloper.io to design a spectacular React Native application for your business.

Consult with experts:- https://bit.ly/2A8L4vz

#hire dedicated react native developer #react native development company #react native development services #react native development #react native developer #react native

Juned Ghanchi

1621573085

React Native App Developers India, React Native App Development Company

Expand your user base by using react-native apps developed by our expert team for various platforms like Android, Android TV, iOS, macOS, tvOS, the Web, Windows, and UWP.

We help businesses to scale up the process and achieve greater performance by providing the best react native app development services. Our skilled and experienced team’s apps have delivered all the expected results for our clients across the world.

To achieve growth for your business, hire react native app developers in India. You can count on us for all the technical services and support.

#react native app development company india #react native app developers india #hire react native developers india #react native app development company #react native app developers #hire react native developers

Hire Dedicated React Native Developers - WebClues Infotech

Being one of the emerging frameworks for app development the need to develop react native apps has increased over the years.

Looking for a react native developer?

Worry not! WebClues infotech offers services to Hire React Native Developers for your app development needs. We at WebClues Infotech offer a wide range of Web & Mobile App Development services based o your business or Startup requirement for Android and iOS apps.

WebClues Infotech also has a flexible method of cost calculation for hiring react native developers such as Hourly, Weekly, or Project Basis.

Want to get your app idea into reality with a react native framework?

Get in touch with us.

Hire React Native Developer Now: https://www.webcluesinfotech.com/hire-react-native-app-developer/

For inquiry: https://www.webcluesinfotech.com/contact-us/

Email: sales@webcluesinfotech.com

#hire react native developers #hire dedicated react native developers #hire react native developer #hiring a react native developer #hire freelance react native developers #hire react native developers in 1 hour

Factors affecting the cost of hiring a React Native developer in USA - TopDevelopers.co

Want to develop app using React Native? Here are the tips that will help to reduce the cost of react native app development for you.
Cost is a major factor in helping entrepreneurs take decisions about investing in developing an app and the decision to hire react native app developers in USA can prove to be fruitful in the long run. Using react native for app development ensures a wide range of benefits to your business. Understanding your business and working on the aspects to strengthen business processes through a cost-efficient mobile app will be the key to success.

#best react native development companies from the us #top react native app development companies in usa #cost of hiring a react native developer in usa #top-notch react native developer in usa #best react native developers usa #react native