• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

아이폰으로 회원가입

23.05.22 15:42 작성 조회수 407

0

안녕하세요 제로초님 아이폰으로 회원가입 할려는데

안드로이드는 잘되지만 아이폰만 안되서 질문 드립니다

강의 교안 보고 Podfile에 pod 'react-native-config', :path => '../node_modules/react-native-config/react-native-config.podspec' 추가해보기 해봤는데

회원가입이 안되고 로그에 undefined가 계속 뜨네요

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'
pod 'react-native-config', :path => '../node_modules/react-native-config/react-native-config.podspec'
target 'FoodDeliveryApp' do
  config = use_native_modules!
  
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'FoodDeliveryAppTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

여기에 추가하는게 맞나요?

답변 1

답변을 작성해보세요.

0

아이폰에서 백엔드 ip 뭘로 하셨나요?

장산님의 프로필

장산

질문자

2023.05.22

API_URL = http://192.168.x.x:3105

따로 설정하지는 않았지만 게시물 보고 맥북=>설정=> 네트워크에서 ip주소 가져온것으로 했습니다!

아이폰 시뮬레이터인가요? 사파리에서 그 백엔드 주소 입력해보세요.

장산님의 프로필

장산

질문자

2023.05.22

ok라고 뜹니다! 그러면 잘된다는것인데...

아 위에 ip로 하니까 이번에는 안드로이드가 안됩니다 흠

axios 요청보내는 곳에서 api url이 undefined 뜨는건가요?

장산님의 프로필

장산

질문자

2023.05.22

try {
      setLoading(true);
      const response = await axios.post(`${Config.API_URL}/user`, {
        email,
        name,
        password,
      });
      console.log('이메일이름비번',response.data);
      setLoading(false);
      Alert.alert("알림", "회원가입 되었습니다");
      navigation.navigate("SignIn");
    } catch (error) {
      //error는 unknown이라서 실제로 뭔지 모르기때문에 사용할때 한번 지정해줘야함
      const errorResponse = (error as AxiosError).response;
      console.log("error2", errorResponse);
      if (errorResponse) {
        Alert.alert("알림", errorResponse.data.message);
      }
    } finally {
      setLoading(false);
    }
    Alert.alert("알림", "회원가입 되었습니다.");
  }, [loading, navigation, email, name, password]);errorResponse

errorResponse가 undifined뜹니다

error reponse말고 error를 찍어보세요. 그리고 api url도요

장산님의 프로필

장산

질문자

2023.05.23

url을  http://10.0.2.2:3105 으로 했을경우

안드로이드는 url이  http://10.0.2.2:3105 로 뜨고

프론트에러는 아래것이 뜨지만 백엔드에는 성공했다고 뜨면서 로그인창으로 넘어가집니다

스크린샷 2023-05-23 오전 12.55.40.pngios는 url이 http://10.0.2.2:3105 뜨고

[Error: timeout exceeded] 이에러가 뜨면서 회원가입 되었습니다라고 알림창은 뜨는데 백엔드는 반응이 없습니다

ios는 api url 192로 시작해야하는 겁니다.

장산님의 프로필

장산

질문자

2023.05.23

아그럼 .env에서 192로 바꿔도  http://10.0.2.2:3105 로그창에 이렇게 뜨네요

 

캐시같은게 남아있는것 같은데 xcode에서 build에서 cache clean하고 다시 빌드해야할 것 같네요.

장산님의 프로필

장산

질문자

2023.05.23

xcode에서 product메뉴에서 clean build folder 하고 다시 빌드 했더니 성공했습니다! 감사합니다!