如何使用React Native使用Firebase Twitter身份验证?
我在参考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时,什么也没发生.
我该如何解决这个问题?
或者这不可能吗?