14.5 C
New York
Wednesday, November 20, 2024

ios – Firestore API failed to attach crashing my app


Each time I swap from mock Information to actual knowledge from my firebase, my app crashes.
(https://i.sstatic.internet/7UYBbfeK.png)

As quickly as I modify this 3 strains of code my app crashes

Predominant Code

import SwiftUI

struct InboxView: View {
    
    @State non-public var showNewMessageView = false
//    @StateObject var viewModel = InboxViewModel() // uncomment this
    @State non-public var consumer = Consumer.MOCK_USER // remark out this
    
//    non-public var consumer: Consumer? { //uncomment this
//        return viewModel.currentUser
//    }
    
    var physique: some View {
        NavigationStack {
            ScrollView {
                ActiveNowView()
                
                Checklist {
                    ForEach(0 ... 10, id: .self) { message in
                        InboxRowView()
                    }
                }
                .listStyle(PlainListStyle())
                .body(peak: UIScreen.predominant.bounds.peak - 120)
            }
            .navigationDestination(for: Consumer.self, vacation spot: { consumer in
                ProfileView(consumer: consumer)
            })
            .fullScreenCover(isPresented: $showNewMessageView, content material: {
                NewMessageView()
            })
            .toolbar {
                ToolbarItem(placement: .topBarLeading) {
                    HStack {
                        NavigationLink(worth: consumer) {
                            CircularProfileImageView(consumer: consumer, measurement: .xsmall)
                        }
                        
                        Textual content("Chats")
                            .font(.title)
                            .fontWeight(.semibold)
                    }
                }
                
                ToolbarItem(placement: .topBarTrailing) {
                    Button {
                        showNewMessageView.toggle()
                    } label: {
                        Picture(systemName: "sq..and.pencil.circle.fill")
                            .resizable()
                            .body(width: 32, peak: 32)
                            .foregroundStyle(.black, Shade(.systemGray5))
                    }
                }
            }
        }
    }
}

InboxViewModel

import Basis
import Mix
import Firebase

class InboxViewModel: ObservableObject {
    
    @Revealed var currentUser: Consumer?
    
    non-public var cancellabels = Set()
    
    init() {
        setupSuscribers()
    }
    
    non-public func setupSuscribers() {
        UserService.shared.$currentUser.sink { [weak self] consumer in
            self?.currentUser = consumer
        }.retailer(in: &cancellabels)
    }
}

Consumer

import FirebaseFirestore
import SwiftUI
import Firebase

struct Consumer: Codable, Identifiable, Hashable {
    @DocumentID var uid: String?

    let fullname: String
    let e-mail: String
    let profileImageUrl: String?
    
    var id: String {
        return uid ?? NSUUID().uuidString
    }
}

extension Consumer {
    static let MOCK_USER = Consumer(fullname: "Bruce Wayne", e-mail: "[email protected]", profileImageUrl: "batman")
}

The Terminal throws this error as quickly as I run my code

I0000 00:00:1732088994.725995 1362774 subchannel.cc:806] subchannel 0x101c70a80 {deal with=ipv6:%5B2404:6800:4002:81a::200apercent5D:443, args={grpc.client_channel_factory=0x60000002b3e0, grpc.default_authority=firestore.googleapis.com, grpc.http2_scheme=https, grpc.inside.channel_credentials=0x60000263cb40, grpc.inside.client_channel_call_destination=0x103d64828, grpc.inside.event_engine=0x60000002b4e0, grpc.inside.security_connector=0x600002c2d900, grpc.inside.subchannel_pool=0x600002949500, grpc.keepalive_time_ms=30000, grpc.primary_user_agent=grpc-c++/1.65.1, grpc.resource_quota=0x600000c99680, grpc.server_uri=dns:///firestore.googleapis.com}}: join failed (UNKNOWN:(area:NSPOSIXErrorDomain, code:50, description:The operation couldn’t be accomplished. Community is down) {file:”/var/folders/hn/5bx1f4_d4ds5vhwhkxc7vdcr0000gn/T/ZipRelease/2024-07-25T04-01-28/project-ios/Pods/gRPC-Core/src/core/lib/transport/error_utils.cc”, file_line:150, created_time:”2024-11-20T13:19:54.724606+05:30″, grpc_status:2}), backing off for 874 ms

DEBUG: Present consumer is Elective(Messenger.Consumer(_uid: FirebaseFirestore.DocumentID(worth: Elective(“Tg2TbvUlWBdjtL1XKkFJD6MeGKn1”)), fullname: “Bruce Wayne”, e-mail: “[email protected]“, profileImageUrl: nil))

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles