Nitesh
Nitesh

Reputation: 2034

Use of undeclared type 'Firebase'

I know this is one of the most asked question but still couldn't find the problem.

I tried updating pod but still this error.

import Firebase

public static func createUrlToGetMessages(threadId id: String) -> Firebase {
    return Firebase(url: FIREBASE_BASE_REF)
        .childByAppendingPath("chats")
        .childByAppendingPath(id)
        .childByAppendingPath("messages")
}
public static func createUrlToGetOneMessageRef(threadId threadId: String, messageId messageId: String) -> Firebase {
    return Firebase(url: FIREBASE_BASE_REF)
        .childByAppendingPath("chats")
        .childByAppendingPath(threadId)
        .childByAppendingPath("messages")
        .childByAppendingPath(messageId)
}

enter image description here

Upvotes: 2

Views: 1255

Answers (1)

mixel
mixel

Reputation: 25876

It seems that you are using old deprecated version of Firebase.

Read the new docs for the setup details.

Your code should be like this:

import Firebase

var ref = FIRDatabase.database().reference()

public static func createUrlToGetMessages(threadId id: String) -> FIRDatabaseReference {
    return ref.child("chats").child(id).child("messages")
}

public static func createUrlToGetOneMessageRef(threadId: String, messageId: String) -> FIRDatabaseReference {
    return ref.child("chats").child(threadId).child("messages").child(messageId)
}

Upvotes: 4

Related Questions