programing

Google Sign In 버튼을 클릭하면 앱이 다운됩니다.

megabox 2023. 11. 5. 11:07
반응형

Google Sign In 버튼을 클릭하면 앱이 다운됩니다.

구글 로그인 SDK 4.0.1을 사용하고 있습니다.구글 사인인 버튼을 누르면 앱이 다운됩니다.그리고 이 문제를 해결하는 방법은 다음과 같습니다.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Your app is missing support for the following URL schemes: com.googleusercontent.apps.107731993306-6s44u18onibp6gi0ddj94si1aifshhg6'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000101ac0d4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010110121e objc_exception_throw + 48
    2   CoreFoundation                      0x0000000101b2a2b5 +[NSException raise:format:] + 197
    3   xxxxx                           0x000000010084b3cb -[GIDSignIn signInWithOptions:] + 246
    4   xxxxx                           0x000000010084efc2 -[GIDSignInButton pressed] + 242
    5   UIKit                               0x00000001028f78bc -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKit                               0x0000000102a7dc38 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x0000000102a7df51 -[UIControl _sendActionsForEvents:withEvent:] + 444
    8   UIKit                               0x0000000102a7ce4d -[UIControl touchesEnded:withEvent:] + 668
    9   UIKit                               0x0000000102965545 -[UIWindow _sendTouchesForEvent:] + 2747
    10  UIKit                               0x0000000102966c33 -[UIWindow sendEvent:] + 4011
    11  UIKit                               0x00000001029139ab -[UIApplication sendEvent:] + 371
    12  UIKit                               0x000000010310072d __dispatchPreprocessedEventFromEventQueue + 3248
    13  UIKit                               0x00000001030f9463 __handleEventQueue + 4879
    14  CoreFoundation                      0x0000000101a65761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x0000000101a4a98c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x0000000101a49e76 __CFRunLoopRun + 918
    17  CoreFoundation                      0x0000000101a49884 CFRunLoopRunSpecific + 420
    18  GraphicsServices                    0x00000001074cfa6f GSEventRunModal + 161
    19  UIKit                               0x00000001028f5c68 UIApplicationMain + 159
    20  xxxxxxxx                           0x00000001007c449f main + 111
    21  libdyld.dylib                       0x0000000104d5368d start + 1
    22  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException`

내 앱 대리인.스위프트는

class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
   if (error == nil) {

    let userId:NSString = user.userID as NSString;                  // For client-side use only!
    let idToken: NSString = user.authentication.idToken as NSString; // Safe to send to the server
    let fullName:NSString = user.profile.name as NSString;
    let givenName:NSString = user.profile.givenName as NSString;
    let familyName:NSString = user.profile.familyName as NSString;
    let email:NSString = user.profile.email as NSString;
    print(userId)
    print(userId,idToken,fullName,givenName,familyName,email)
    }

   else {
    print("\(error.localizedDescription)")
    }
}

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    let kclientID:NSString = "107731993306-xxxxxxxxxxxxxxxxx.apps.googleusercontent.com"

   GIDSignIn.sharedInstance().clientID = kclientID as String!

    GIDSignIn.sharedInstance().delegate = self
    return true
}


func application(application: UIApplication,
                 openURL url: NSURL, options: [String: AnyObject], annotation:Any, sourceApplication:String?) -> Bool {

    return GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication:sourceApplication, annotation: annotation)
} 

해결책을 제시해 주십시오.왜 추락한 거지?

오류가 분명하게 말해주듯이, 당신의 앱은 url scheme에 대한 지원이 없습니다.

info.plist에 다음 구성을 추가합니다.

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>***Your bundle ID***</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>com.googleusercontent.apps.107731993306-6s44u18onibp6gi0ddj94si1aifshhg6</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>***Something here***</string>
        </array>
    </dict>
</array>

이 url에서 아이디를 확인하세요 => https://developers.google.com/identity/sign-in/ios/start-integrating . https://developers.google.com/identity/sign-in/ios/start-integrating

info.plist는 ->와 같이 보여야 합니다.

enter image description here

프로젝트에 URL 스킴을 추가해야 합니다.

  1. 프로젝트 구성 열기: 왼쪽 트리 보기에서 프로젝트 이름을 두 번 클릭합니다.TARGETS 섹션에서 앱을 선택한 다음 Info 탭을 선택하고 URL Type 섹션을 펼칩니다.
  2. + 버튼을 클릭하고 URL 스키마를 추가합니다 -com.google 사용자 content.apps.107731993306-6s44u18onibp6gi0ddj94si1aifshh

https://developers.google.com/identity/sign-in/ios/start-integrating#add_a_url_scheme_for_google_sign-in_to_your_project

enter image description here

저도 그 충돌 사고를 당했습니다.하지만 승낙된 대답은 저에게 도움이 되지 않았습니다.다른 방법으로 사고를 고쳤습니다.

다시 확인해 보십시오.

AppDelegate 직선 DNS:

GIDSignIn.sharedInstance().clientID = "536164374389-ivga9a9at2g31nfmhpvdyhc98yf6afnr.apps.googleusercontent.com"

Info.plist DNS 역방향:

<string>com.googleusercontent.apps.536164374389-ivga9a9at2g31nfmhpvdyhc98yf6afnr</string>

Xcode는 문자열을 제공합니다 - 아래 이미지와 같이 여기에 입력합니다.

enter image description here

저도 비슷한 문제에 부딪혔습니다.다른 방법이 도움이 되지 않았다면 이 방법을 사용해 보십시오.

구글과 페이스북 로그인을 함께 구현하는 경우가 많아 함께 구현할 가능성이 있습니다.

최신 Google Dev 문서를 사용하면 프로젝트 대상 > 정보 > URL 유형을 사용하여 URL 스킴을 구현할 수 있습니다.페이스북 문서들은 당신에게 url scheme을 실행하라고 말할 것입니다.info.plistfile. plist 파일로 구현하면 다른 URL Scheme이 대체됩니다.따라서 Project의 Target 섹션에서 모든 URL Scheme을 구현합니다.

프로젝트 대상은 다음과 같습니다.

누군가 이것이 도움이 되기를 바랍니다.

Flutter에서 와주신 분들께는.google_sign_iniOS 기기의 패키지 - 이미 여기서 이 문제를 다루었습니다.

긴 이야기 요약: 속성을 명시적으로 설정해 봅니다.hostedDomain그리고.clientId.

GoogleSignIn googleSignIn = GoogleSignIn( 
  scopes: ['email', 'profile'],
  hostedDomain: "", 
  clientId: "",);

당신은 일반적인 것 대신에 역클라이언트 ID를 추가해야 합니다.

유사한 로그를 위해 4시간 이상을 낭비했습니다(VScode로 flooter해서 ios app을 개발하고 있습니다).

제게 가장 큰 문제는 GoogleService-Info.plist가 실제로 Runner 디렉토리에 있지 않다는 것입니다.

Runner와 add files 버튼을 마우스 오른쪽 버튼으로 클릭하여 GoogleService-Info.plist를 XCODE로 추가해야 했습니다.

전반적으로 The flotter debugger(또는 vScode plugin?)가 오류에 대한 전체 정보를 제공하지 않는다는 것을 알게 되었습니다.

자세한 내용은 https://github.com/flutter/flutter/issues/22536 에서 확인하시기 바랍니다.

이 이미지에서 'Right Clicking Runner and than add files' 항목을 확인합니다.

GoogleSignIn SDK 5.0에서

코드를 추가합니다

GIDsignIn.sharedInstance().delegate = self

GIDsignIn.sharedInstance().ViewController = self를 표시합니다.

이 코드 대신에

GIDsignIn.sharedInstance().delegate = self

GIDsignIn.sharedInstance().uiDelegate = self

저의 경우, 리액티브 파이어베이스를 사용하여 웹과 ios clientiD를 모두 설정하고 iosClientId만 사용하여 해결했습니다.GoogleSignin.configure({ webClientId: '' });

URL을 다음과 같이 반전시키기만 하면 됩니다.com.googleusercontent.apps.app_id

url types는 마침내 이렇게 보입니다.

제 경우에는 두 개의 info.plist 파일을 가지고 있었는데, 하나는 debbug용이고 하나는 프로덕션용입니다. 둘 다 동일한 URL Scheme을 가지고 있는지 확인하세요.

만약 누군가가 위의 모든 옵션을 시도했지만 여전히 같은 오류가 발생한다면요.Google 서비스를 추가하는 것을 잊지 마십시오.프로젝트에 파일을 나열합니다.

저의 경우 파이어베이스에서 Xcode 프로젝트로 GoogleService-info.plist를 내보내는 것을 잊어버렸습니다.

언급URL : https://stackoverflow.com/questions/42197729/app-getting-crash-when-click-on-googlesignin-button

반응형