Cannot read property 'logInWithReadPermissions' of undefined, but there is LoginManager

Viewed 716

I am using react-native (0.55.3) and react-native-fbsdk (0.8.0) to enable Facebook auth.

    import React, { Component } from 'react';
    import { AccessToken, LoginManager } from 'react-native-fbsdk';
    import firebase from 'react-native-firebase';
    ...
    // In the middle of a function
    console.log(LoginManager);
    const test = await LoginManager.logInWithReadPermissions(['public_profile']);
    console.log(test);
    LoginManager.logInWithReadPermissions(['public_profile'])
    .then((result) => {
        console.log(result);
    })
    .catch((err) => {
        console.log(err);
    })


// The following is the result from console.log(LoginManager)
getDefaultAudience: ƒ getDefaultAudience()
getLoginBehavior: ƒ getLoginBehavior()
logInWithPublishPermissions: ƒ logInWithPublishPermissions(permissions)
logInWithReadPermissions: ƒ logInWithReadPermissions(permissions)
logOut: ƒ logOut()
setDefaultAudience: ƒ setDefaultAudience(defaultAudience)
setLoginBehavior: ƒ setLoginBehavior(loginBehavior)
__proto__: Object

// Result from console.log(test); or console.log(err);
TypeError: Cannot read property 'logInWithReadPermissions' of undefined

One weird thing is that I know that LoginManager is defined, and I see that it has logInWithReadPermissions function. Whenever I try to use the function, however, it says that LoginManager is undefined, and I cannot use it.

Is there anybody who encountered same / similar issue?

1 Answers

Had the same issue on ios. For me these steps works:

  • react-native link react-native-fbsdk
  • Libraries > RCTFBSDK.xcodeproj > Build Settings > Framework Search Paths > $(HOME)/Documents/FacebookSDK (recursive)
Related