admin管理员组文章数量:1326672
I am implementing fb sdk in react native app. I have done all changes from link, and running in android device. App crashes on Facebook login button click and these are logs.
05-23 10:42:20.559 7063-7063/.fbsample E/AndroidRuntime: FATAL EXCEPTION: main
Process: .fbsample, PID: 7063
Cannot pass a read permission (email) to a request for publish authorization
at .facebook.login.LoginManager.validatePublishPermissions(LoginManager.java:444)
at .facebook.login.LoginManager.logInWithPublishPermissions(LoginManager.java:416)
at .facebook.login.widget.LoginButton$LoginClickListener.performLogin(LoginButton.java:753)
at .facebook.login.widget.LoginButton$LoginClickListener.onClick(LoginButton.java:725)
at .facebook.FacebookButtonBase$1.onClick(FacebookButtonBase.java:384)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at .android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at .android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
I searched a lot but none helped me to get rid of this issue.
At least error should contain a suggestion to do.
I am stuck from hours :/
There is nothing new from facebook doc.
I have FBLoginButton.js
import React, { Component } from 'react';
import { View } from 'react-native';
import { LoginButton } from 'react-native-fbsdk';
export default class FBLoginButton extends Component {
render() {
return (
<View>
<LoginButton
publishPermissions={["email"]}
onLoginFinished={
(error, result) => {
if (error) {
alert("Login failed with error: " + error.message);
} else if (result.isCancelled) {
alert("Login was cancelled");
} else {
alert("Login was successful with permissions: " + result.grantedPermissions)
}
}
}
onLogoutFinished={() => alert("User logged out")}/>
</View>
);
}
};
module.exports = FBLoginButton;
And App.js
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
var FBLoginButton = require('./FBLoginButton');
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<Text style={styles.label}>Wele to the Facebook SDK for React Native!</Text>
<FBLoginButton />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
wele: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
Some one tell why this issue persist and what can i do to resolve it.
I am implementing fb sdk in react native app. I have done all changes from link, and running in android device. App crashes on Facebook login button click and these are logs.
05-23 10:42:20.559 7063-7063/.fbsample E/AndroidRuntime: FATAL EXCEPTION: main
Process: .fbsample, PID: 7063
Cannot pass a read permission (email) to a request for publish authorization
at .facebook.login.LoginManager.validatePublishPermissions(LoginManager.java:444)
at .facebook.login.LoginManager.logInWithPublishPermissions(LoginManager.java:416)
at .facebook.login.widget.LoginButton$LoginClickListener.performLogin(LoginButton.java:753)
at .facebook.login.widget.LoginButton$LoginClickListener.onClick(LoginButton.java:725)
at .facebook.FacebookButtonBase$1.onClick(FacebookButtonBase.java:384)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at .android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at .android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
I searched a lot but none helped me to get rid of this issue.
At least error should contain a suggestion to do.
I am stuck from hours :/
There is nothing new from facebook doc.
I have FBLoginButton.js
import React, { Component } from 'react';
import { View } from 'react-native';
import { LoginButton } from 'react-native-fbsdk';
export default class FBLoginButton extends Component {
render() {
return (
<View>
<LoginButton
publishPermissions={["email"]}
onLoginFinished={
(error, result) => {
if (error) {
alert("Login failed with error: " + error.message);
} else if (result.isCancelled) {
alert("Login was cancelled");
} else {
alert("Login was successful with permissions: " + result.grantedPermissions)
}
}
}
onLogoutFinished={() => alert("User logged out")}/>
</View>
);
}
};
module.exports = FBLoginButton;
And App.js
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
var FBLoginButton = require('./FBLoginButton');
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<Text style={styles.label}>Wele to the Facebook SDK for React Native!</Text>
<FBLoginButton />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
wele: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
Some one tell why this issue persist and what can i do to resolve it.
Share Improve this question asked May 23, 2018 at 5:23 Khemraj SharmaKhemraj Sharma 59k28 gold badges213 silver badges226 bronze badges3 Answers
Reset to default 5you have to change publishPermissions={["email"]}
to readPermissions={["email"]}
I changed publishPermissions={["email"]}
to publishPermissions={["publish_actions"]}
, and everything worked.
If you intent to get user's email. You must use readPermissions={['email']}
on LoginButton
from react-native-fbsdk
. Please note if you already built the react native app with publishPermissions={["email"]}
like in your question, remove the app and then build again.
Also, you can only use either of readPermissions
or publishPermissions
, not both. This is by design as documented here: https://developers.facebook./docs/reference/android/current/class/LoginButton/#setReadPermissions
If you want to use readPermissions
and publishPermissions
on the same app you must invoke the login dialog again. react-native-fbsdk
provide this with LoginManager
.
The LoginManager class is used to request additional permissions for a session or to provide login functionality using a custom UI. Like LoginButton, the LoginManager class is loaded from the react-native-fbsdk module. The example below performs a login with minimal permissions. https://developers.facebook./docs/react-native/login
本文标签:
版权声明:本文标题:javascript - React native Cannot pass a read permission (email) to a request for publish authorization - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742202689a2432252.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论