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

问题描述 投票:0回答:0
``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];
}
`

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

ios react-native twitter twitter-oauth react-native-twitter-signin
© www.soinside.com 2019 - 2024. All rights reserved.