2016-05-04 41 views
0

我無法獲得React Native中的fbsdk中的AccessToken。React Native中的AccessToken的問題FBSDK

我打電話核心被Facebook的建議:

const FBSDKCore = require('react-native-fbsdkcore'); 
const { 
    FBSDKAccessToken, 
} = FBSDKCore; 

而在一個場景中我嘗試寫日誌中的令牌通過這裏所說的SO一similair問題的建議。

<View> 
     <View style={{flex: 1, alignItems: 'center', padding: 50, marginTop: 250}}> 
     <View> 
      <LoginButton 
      publishPermissions={["publish_actions"]} 
      onLoginFinished={ 
       (error, result) => { 
       if (error) { 
        alert("login has error: " + result.error); 
       } else if (result.isCancelled) { 
        alert("login is cancelled."); 
       } else { 
        FBSDKAccessToken.getCurrentAccessToken((token)=> { 
         console.log(token); 
         });       
        Actions.Navigator() 
       } 
       } 
      } 
      onLogoutFinished={() => { 
       alert("logout.")}}/> 
     </View> 
     </View> 
    </View> 

這給了我redscreen「不確定是不是(評估FBSDKAccessTokenInterface.getCurrentAccessToken)

試圖拉斷的東西在應用程序的其他部分similair,當然定義常量FBSDKAccessToken第一個對象,然後調用userID(這應該是FBSDKCore的一部分)爲:

<Text style={{fontSize: 18, color:colors.General.navtext}}>{FBSDKAccessToken.userID}</Text> 

息率什麼都沒有,在那裏我相信它返回的登錄用戶的用戶ID另外,如果我嘗試在相同的地方寫出accesstoken:

<Text style={{fontSize: 18, color:colors.General.navtext}}>{FBSDKAccessToken.getCurrentAccessToken()}</Text> 

我得到和以前一樣的紅色屏幕。

我試圖尋找鏈接的庫,但這甚至導致進一步的問題。

因此,由此,我很困難,我真的很感謝有什麼問題的反饋。

回答

0

試試這個。

console.log(token.accessToken.toString()); 
相關問題