2016-06-16 5 views
0

Firebase에서 다소 이상한 문제가 발생합니다. Google Base-Info.plist 등의 cocoaPod를 통해 firebase를 설치했지만 Firebase에서 값을 읽으려고하면 오류 : 나는 한 시간에서 제외하고, 새 프로젝트를 시작하려고 노력이 매번 입수했습니다Swift/Firebase 데이터베이스 유효하지 않은 토큰 오류

2016-06-16 12:10:04.598 MP[78421:13128189] [FirebaseDatabase] Authentication failed: invalid_token (Invalid claim 'aud' in auth token.)

-하지만 새로운 것을 시작하고 나는이 지금이 프로젝트를 포기했다. 여기에 간단한 코드는 다음과 같습니다

import UIKit 
import Firebase 
import FirebaseDatabase 
class ViewController: UIViewController { 
    var ref:FIRDatabaseReference! 
    override func viewDidLoad() { 
     super.viewDidLoad() 
     ref = FIRDatabase.database().reference() 
     ref.observeSingleEventOfType(.Value) { (snapshot:FIRDataSnapshot) in 
      var val = snapshot.value! as? String 
      print(val) 
     } 
    } 
} 

나는이 문제를 해결할 수있는 방법?

답변

6

이 오류 메시지는 토큰의 프로젝트가 응용 프로그램이 연결되어있는 프로젝트와 일치하지 않음을 나타냅니다. post on the firebase-talk group A로부터 :

There are a couple ways you may hit this:

  1. You've changed your GoogleService-Info.plist to point at a different project, but your app still has a cached token from a previous run.

  2. I believe the iOS Simulator shares the keychain between apps, so if you have multiple apps using Firebase, one app might be picking up the token cached by another app. This only happens in the simulator and we're working on changing the Firebase SDK to avoid this.

In either case, you can probably resolve the issue by doing an explicit signOut() call before initializing Firebase Database.

+1

나는 FIRAuth.auth했다()? signout - 그리고 지금은 모든 작품! 감사! – askaale

+0

반가워요. 우리는 이러한 행동을 개선하기 위해 노력하고 있습니다. 내 대답이 유용했다면 왼쪽에있는 upvote 버튼을 클릭하십시오. 질문에 답한 경우 체크 표시를 클릭하십시오. 그런 식으로 다른 사람들은 당신이 (충분히) 도움을 받았다는 것을 알게됩니다. –

+2

이것은 나를 위해 작동하지 않았다. 기기에서도 발생합니다. Sim을 지우고 두 앱 모두에서 로그 아웃했습니다. 여전히 토큰에 대해 불평하고 있습니다. 어떻게 고칠 지 모르겠다. –

관련 문제