expo clerk oauth 无法深入链接到未定义自定义方案的独立应用程序

问题描述 投票:0回答:1

我正在使用 Clerk 来完成我的世博会项目。

我按照他们的文档

进行我的宣誓

这是我的代码:

import React, { useCallback } from 'react';
import { TouchableOpacity, View, StyleSheet, Image, Alert } from 'react-native';
import * as WebBrowser from "expo-web-browser";
import { useOAuth } from '@clerk/clerk-expo';

import { useWarmUpBrowser } from '../hooks/warmUpBrowser';


WebBrowser.maybeCompleteAuthSession();

const OAuthButtons = () => {

  useWarmUpBrowser();

  const { startOAuthFlow: startGoogleOAuthFlow } = useOAuth({ strategy: 'oauth_google' });
  const { startOAuthFlow: startFacebookOAuthFlow } = useOAuth({ strategy: 'oauth_facebook' });
  const { startOAuthFlow: startAppleOAuthFlow } = useOAuth({ strategy: 'oauth_apple' });

  const onPressOAuth = useCallback(async (provider) => {
    try {
      const startOAuthFlow = 
        provider === 'google' ? startGoogleOAuthFlow :
        provider === 'facebook' ? startFacebookOAuthFlow :
        startAppleOAuthFlow;

      const { createdSessionId, setActive } = await startOAuthFlow();

      if (createdSessionId) {
        setActive({ session: createdSessionId });
      } else {
        // Handle the case where additional steps are needed
      }
    } catch (err) {
      Alert.alert("OAuth Error", `An error occurred during the OAuth process: ${err.message || err}`);
      console.error("OAuth error", err);
    }
  }, []);

  return (
    <View style={styles.oauthContainer}>
      {/* Google Sign-In Button */}
      <TouchableOpacity onPress={() => onPressOAuth('google')} style={styles.oauthButton}>
        <Image source={require('../assets/images/logos/google_logo.png')} style={{width: 40, height: 41.15, marginTop: 0.8}} />
      </TouchableOpacity>

      {/* Apple Sign-In Button */}
      <TouchableOpacity onPress={() => onPressOAuth('apple')} style={styles.oauthButton}>
        <Image source={require('../assets/images/logos/apple_logo.png')} style={{width: 40, height: 42, marginBottom: 2}} />
      </TouchableOpacity>

      {/* Facebook Sign-In Button */}
      <TouchableOpacity onPress={() => onPressOAuth('facebook')} style={styles.oauthButton}>
        <Image source={require('../assets/images/logos/fb_logo.png')} style={{width: 42, height: 42}} />
      </TouchableOpacity>
    </View>
  );
};

它在模拟器上运行良好,但当通过 TestFlight 部署到我的 iPhone 时,我得到:

Cannot make a deep link into a standalone app with no custom scheme defined

我看过帖子展示了如何深度链接应用程序,但我想它应该由职员处理。有什么建议吗?

reactjs react-native oauth-2.0 expo clerk
1个回答
0
投票

将其添加到您的 app.json 或 app.config.json 中

{ “博览会”:{ ...

 "scheme": "Name Of your app"

} }

© www.soinside.com 2019 - 2024. All rights reserved.