2016-10-02 166 views
1

我使用的反应母语为Facebook日志中,你可以在下面的链接上看到的,我有一些问题,与Facebook登录渲染:阵营本地渲染Facebook登录

enter image description here

要获得那首先我做了:rnpm install react-native-fbsdk(安装facebook依赖项)。

然后我说的基本知识Facebook的代码教程(https://developers.facebook.com/docs/react-native/login):

const FBSDK = require('react-native-fbsdk'); 
const { 
    LoginButton, 
} = FBSDK; 

var Login = React.createClass({ 
    render: function() { 
     return (
      <View> 
       <LoginButton 
        publishPermissions={["publish_actions"]} 
        onLoginFinished={ 
         (error, result) => { 
          if (error) { 
           alert("Login failed with error: " + result.error); 
          } else if (result.isCancelled) { 
           alert("Login was cancelled"); 
          } else { 
           alert("Login was successful with permissions: " + result.grantedPermissions) 
          } 
         } 
        } 
        onLogoutFinished={() => alert("User logged out")}/> 
      </View> 
     ); 
    } 
}); 

最后,我添加了这样的Android清单我的Facebook API密钥: (元数据)安卓名=“融为一体。 “facebook.sdk.ApplicationId”android:value =“@ string/facebook_app_id”/>

你有什么想法解决这个问题吗?非常感谢你的回答 !

回答

0

我找到了解决办法...

的问题是从MainApplication.java和MainActivity.java未来(在android系统/应用程序)。

Facebook的文档已过期...(仅适用于反应原生版本< 0.29 ...)。

+1

你是如何解决这个问题的?我使用的版本> 0.29在Android –

+0

要最认真,我不记得解决方案... 但请参考我的答案,你应该看看https://github.com/Sachavent/Learning_React-Native/blob/ master/android/app/src/main/java/com/comeet/MainActivity.java和https://github.com/Sachavent/Learning_React-Native/blob/master/android/app/src/main/java/com/ comeet/MainApplication.java 并将其与facebook文档进行比较... 告诉我它是否有帮助;) – Sachavent

+0

谢谢,我用代码更新了我的代码,并且它工作正常。我不知道是什么问题,但它只是工作:)。 –