我正在尝试让FB SDK与iOS上的React-Native应用程序一起使用,但遇到了以下错误:
React-Native-无法读取未定义的属性'logInWithReadPermissions'
在按钮上单击。
我已经按照以下说明进行操作:
1. npm install rnpm -g
2. rnpm link react-native-fbsdk
3. remove the following lines from subspecs in ios/PodFile
'Core',
'Login',
'Share',
4. pod install
5. go to https://developers.facebook.com/docs/ios/getting-started, download FB ios SDK, and unzip to ~/Documents/FacebookSDK
6. open F8v2.xcworkspac with xcode, and drag Bolts.framework,FBSDKCoreKit.framework, FBSDKLoginKit.framework, FBSDKShareKit.framework in ~/Documents/FacebookSDK to Frameworks under F8V2 project.
7. run react-native run-ios .It should work now. If have build issue, drag the three FB...Kit.framework to RCTFBSDK.xcodeproj too.
Run Code Online (Sandbox Code Playgroud)
没运气。
组件流如下所示:
(按钮) …
我使用react-native进行共享,就像在mycode中一样
const FBSDK = require('react-native-fbsdk');
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View,
} from 'react-native';
const {
LoginButton,
ShareDialog,
} = FBSDK;
class HelloFacebook extends Component {
constructor(props) {
super(props);
const shareLinkContent = {
contentType: 'link',
contentUrl: 'https://www.facebook.com',
contentDescription: 'Wow, check out this great site!',
};
this.state = {
shareLinkContent: shareLinkContent,
};
}
shareLinkWithShareDialog() {
var tmp = this;
ShareDialog.canShow(this.state.shareLinkContent).then(
function(canShow) {
if (canShow) {
return ShareDialog.show(tmp.state.shareLinkContent);
}
}
).then(
function(result) {
if …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用react-native-fbsdk(0.4.0)将带有hashtag的图像发布到facebook:
ShareDialog.canShow(shareContent)
.then(canShow => {
if (canShow) {
return ShareDialog.show(shareContent);
} else {
return Promise.reject('error sharing');
}
})
.then(result => {
// evaluating result here
});
Run Code Online (Sandbox Code Playgroud)
当shareContent具有以下内容时,正常显示共享对话框并将内容发布到FB :
shareContent = {
contentType: 'photo',
photos: [{
imageUrl: 'valid uri'
}]
};
Run Code Online (Sandbox Code Playgroud)
当我添加主题标签时,共享对话框不会出现并且result是一个空对象{}:
shareContent = {
contentType: 'photo',
commonParameters: {
hashtag: '#SomeHashTag'
},
photos: [{
imageUrl: 'the same valid uri'
}]
};
Run Code Online (Sandbox Code Playgroud)
此外,如果我尝试添加一个hashtag到其他类型,如link共享对话框工作正常.
我做错了什么?:(
我一直试图react-native-fbsdk与CocoaPods合作,因为我更喜欢将Facebook SDK作为该pod install过程的一部分,但是我运气并不好。我知道我可以react-native link使用npm库并手动下载并添加必要的框架,但是当我拥有一个非常好的软件包管理器时,这似乎很愚蠢。
从文档来看,它应该相当简单-只需将必要的Pod添加到Podfile,对吧?但是,无论我尝试哪种方式,似乎都不会包含本机FBSDK模块。我尝试了很多不同Podfile的,其中一些使用use_framework!和pod 'Bolts',一些使用pod 'FBSDKCoreKit'。这是我目前正在使用的:
target 'FacebookPods' do
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
target 'FacebookPodsTests' do
inherit! :search_paths
end
end
Run Code Online (Sandbox Code Playgroud)
但是,当我运行测试应用程序并尝试对react-native-fbsdk模块执行任何操作时,会收到错误消息,抱怨未定义各种本机模块。这是我的index.ios.js文件,尝试访问LoginManager:
import React, {Component} from "react"
import {AppRegistry, Text} from "react-native"
import {LoginManager} from "react-native-fbsdk"
export default class FacebookPods extends Component {
componentWillMount() {
LoginManager.logInWithReadPermissions(["email"])
.then(() => console.log("Success!"))
.catch((err) => console.log("Failure!", err))
} …Run Code Online (Sandbox Code Playgroud) react-native fbsdk fbsdkloginkit react-native-fbsdk react-native-ios
我正在使用react-native-fbsdk npm软件包,它可以正常工作。但是,当我调用LoginManager.logOut()时,它什么也没做(即使它的回调函数也不起作用)。首次登录后,它保留了我的所有数据,并且在首次登录并从应用程序注销后,它保留了我的所有数据,当我再次按FB图标以使用Facebook登录时,它只允许我使用同一帐户登录。没有其他选择。当我转到浏览器并从Facebook注销时,该应用程序会根据需要运行(并允许我使用其他帐户登录)。但是我需要完全从该应用程序完全注销。请帮助解决问题。提前致谢
我正在使用react-native-fbsdk我的 react-native 应用程序通过 Facebook 登录。
我打电话LoginManager.logOut()给注销:它实际上并没有正确注销,因为我下次尝试登录时,它不会再次要求我输入登录名/密码,所以我只能用一个帐户登录。我找不到登录另一个 Facebook 帐户的方法。
这家伙(react-native-fbsdk:如何正确地从 facebook 注销?)遇到了同样的问题,似乎没有找到解决方案。
iOS 上的一个技巧是转到 safari,然后从移动 facebook 网站注销。虽然这在android上不起作用:(
编辑:
这是我的facebook登录代码:
function login() {
return LoginManager.logInWithReadPermissions(FACEBOOK_PERMISSIONS)
.then(result => {
if (result.isCancelled) {
throw new Error("Login canceled");
}
return AccessToken.getCurrentAccessToken();
})
.then(({ accessToken }) => accessToken);
}
Run Code Online (Sandbox Code Playgroud)
注销/登录视频:https : //d3vv6lp55qjaqc.cloudfront.net/items/132L2U1p383E1y0l2l2v/Screen%20Recording%202018-10-31%20at%2002.52%20PM.mov
我已经使用新的https://github.com/facebook/react-native-fbsdk进行了facebook登录工作,但是我似乎无法获得通常在响应中返回的用户令牌.有人找到了获取此信息的方法吗?另一个SDK的https://github.com/magus/react-native-facebook-login在登录请求中返回它,但新的FB sdk没有,并且github页面上的文档没有在任何地方提及它.
我的团队正在使用 React Native 构建我们的第一个 iOS 应用程序。由于某种原因,仅在我的 Mac 上,运行后构建失败react-native run-ios。自从我们添加 Facebook 身份验证以来,这种情况就一直在发生react-native-fbsdk。
我们都运行node -v 7.0 和最新版本的Xcode。我什至尝试在本地删除存储库并将其克隆回来。作为一个实验,我团队的另一名成员在本地删除了他的存储库,将其克隆回来,并且能够让一切正常运行。我们坐在一起,做了完全相同的步骤,这对他有效,但对我无效。
以下是我在终端中收到的错误消息:
** BUILD FAILED **
The following build commands failed:
CompileC /Users/philmok/js_projects/pLot/ios/build/Build/Intermediates/RCTFBSDK.build/Debug-iphonesimulator/RCTFBSDK.build/Objects-normal/x86_64/RCTFBSDKGraphRequestManager.o RCTFBSDK/core/RCTFBSDKGraphRequestManager.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/pLot.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist …Run Code Online (Sandbox Code Playgroud) 找不到身份提供者配置
当我尝试使用FacebookAuthProvider验证到Firebase时出现此错误。我正在使用react-native-fbsdk与react-native进行Facebook身份验证集成。我的目标是使用身份验证令牌登录用户ti firebase并将用户数据记录在firestore中的USERS集合中。
下面是我的代码。任何帮助表示赞赏。
fbAuth(){
LoginManager.logInWithReadPermissions(['public_profile','email','user_photos']).then(
(result)=>{
this.handleCallBack(result),
function(error){
console.log("error in facebook login.");
}
}
);
}
handleCallBack(result){
var _this = this;
if(result.isCancelled){
console.log("facebook login cancelled.");
}else{
AccessToken.getCurrentAccessToken().then(
(data) => {
const token = data.accessToken;
fetch('https://graph.facebook.com/v2.8/me?fields=id,first_name,last_name,gender,birthday&access_token=' + token)
.then((response=>response.json()))
.then((json)=>{
const imageSize = 120;
const facebookID = json.id;
const fbImage = "https://graph.facebook.com/${facebookID}/picture?height=${imageSize}";
})
this.authenticate(data.accessToken)
.then(result =>{
const {uid} = result;
_this.createUser(uid,json,token,fbImage);
})
})
.catch(error=>{
console.log(error);
})
}
}
authenticate = (token) => {
const provider = firebase.auth.FacebookAuthProvider;
const credential = …Run Code Online (Sandbox Code Playgroud) facebook-login firebase react-native firebase-authentication react-native-fbsdk
我已经使用 facebook sdk 一年多了,我也相应地遵循了文档,但从昨天开始,应用程序开始抛出错误,并且它也出现在之前的版本构建中(直到昨天运行良好)。我检查了其他答案,建议在清单文件中添加字符串,但该字符串已经添加并且在 iOS 上工作正常。
Fatal Exception: com.facebook.FacebookSdkNotInitializedException
The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
com.facebook.internal.Validate.sdkInitialized (Validate.kt:129)
com.facebook.appevents.AppEventsLoggerImpl.<init> (AppEventsLoggerImpl.kt:642)
com.facebook.appevents.AppEventsLoggerImpl.<init> (AppEventsLoggerImpl.kt:82)
com.facebook.appevents.AppEventsLogger.<init> (AppEventsLogger.kt:118)
com.facebook.appevents.AppEventsLogger.<init>
com.facebook.appevents.AppEventsLogger$Companion.newLogger (AppEventsLogger.kt:369)
com.facebook.appevents.AppEventsLogger.newLogger (Unknown Source:2)
com.facebook.reactnative.androidsdk.FBAppEventsLoggerModule.initialize (FBAppEventsLoggerModule.java:129)
com.facebook.react.bridge.ModuleHolder.doInitialize (ModuleHolder.java:236)
com.facebook.react.bridge.ModuleHolder.markInitializable (ModuleHolder.java:100)
com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceInitialized (NativeModuleRegistry.java:129)
com.facebook.react.bridge.CatalystInstanceImpl$2.run (CatalystInstanceImpl.java:452)
Run Code Online (Sandbox Code Playgroud)