在react-native for IOS中使用react-native-twitter-signin登录twitter,但在成功验证后未重定向回应用程序

6ojccjat  于 12个月前  发布在  iOS
关注(0)|答案(1)|浏览(86)
``import React, {useState} from 'react';
import {View, NativeModules, TouchableOpacity, Image} from 'react-native';
import twitter from '../../assets/images/twitter.png';
import {styles} from './styles/SsoLogin';

const {RNTwitterSignIn} = NativeModules;

const TwitterLogin = () => {
  const [isLoading, setIsLoading] = useState(false);
  const TWITTER_CONSUMER_KEY = 'my consumer key';
  const TWITTER_CONSUMER_SECRET =
    'my secret key';

  const handleTwitterLogin = async () => {
    setIsLoading(true);
    RNTwitterSignIn.init(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
    try {
      const {authToken, email} = await RNTwitterSignIn.logIn();
      console.log('yes', authToken);
      console.log('user email', email);
      setIsLoading(false);
    } catch (error) {
      console.log('yes error', error);
      setIsLoading(false);
    }
  };

  return (
    <View>
      <TouchableOpacity style={styles.buttonStyle} onPress={handleTwitterLogin}>
        <Image style={{height: 22, width: 22}} source={twitter} />
      </TouchableOpacity>
    </View>
  );
};

export default TwitterLogin;

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  return [RCTLinkingManager application:app openURL:url options:options];
}
`

字符串
在react-native for IOS中使用react-native-twitter-signin登录twitter,但成功认证后不会重定向回应用程序。成功认证后重定向回我的应用程序。

nnt7mjpx

nnt7mjpx1#

使用RNTwitterSignIn.init从nativeModule获取init错误未找到,并且在nativaModule内未找到任何内容

相关问题