Как использовать Firebase Twitter Authentication с React Native?
Как использовать Firebase Twitter Authentication с React Native?
Я попробовал оба кода ниже в отношенииhttps://www.firebase.com/docs/web/guide/login/twitter.html
var Firebase = require("firebase");
var App = React.createClass({
render: function() {
return (
<View>
<Text onPress={this._handlePress}>
Twitter login
</Text>
</View>
);
},
_handlePress: function () {
var myApp = new Firebase("https://<myapp>.firebaseio.com");
myApp.authWithOAuthRedirect("twitter", function(error) {
if (error) {
console.log("Login Failed!", error);
} else {
// We'll never get here, as the page will redirect on success.
}
});
}
});
а также
var Firebase = require("firebase");
var App = React.createClass({
render: function() {
return (
<View>
<Text onPress={this._handlePress}>
Twitter login
</Text>
</View>
);
},
_handlePress: function () {
var myApp = new Firebase("https://<myapp>.firebaseio.com");
myApp.authWithOAuthPopup("twitter", function(error, authData) {
, if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
}
});
}
});
Когда я используюauthWithOAuthRedirect
произошла ошибка как
undefined is not an object (evaluating 'window.location.href')
Когда я используюauthWithOAuthPopup
, ничего не случилось.
Как я могу решить вопрос? Или это невозможно?