iOS Development

swift – iOS Supabase SDK Add Errors

I’ve a desk I setup in Supabase, partially proven right here:

enter image description here

I am utilizing the Supabase iOS SDK to ship information to the desk:

   class SupabaseAnalyticsManager: ObservableObject {
        static let shared = SupabaseAnalyticsManager()
        personal var consumer: SupabaseClient?
        
        var lastSentClockDrawRecords: [PathData] = []
        var lastSentClockCopyRecords: [PathData] = []
        
        personal init() {
            if let url = URL(string: "myURL") {
                consumer = SupabaseClient(supabaseURL: url, supabaseKey: "mykey")
            } else {
                print("Invalid Supabase URL")
            }
        }

    func insertPathDataForClockCopy(information: [PathData]) async throws {
        if information == lastSentClockCopyRecords {
            return
        }
        
        lastSentClockCopyRecords = information
        
        guard let consumer = consumer else {
            print("Error: Supabase consumer shouldn't be initialized.")
            throw SupabaseError.clientNotInitialized
        }

        do {
            let response = strive await consumer.database.from("clock-copy").insert(values: information).execute()
            print("Batch Insert Response for Clock Copy Path Information: (response)")
            
            if response.standing != 201 {
                print("Error: Batch insertion of Clock Copy path information failed with standing code (response.standing)")
                throw SupabaseError.insertionFailed
            }
        } catch {
            print("Error: An exception occurred whereas batch inserting the Clock Copy path information information. Error particulars: (error)")
            throw error
        }
    }

    enum SupabaseError: Error {
        case clientNotInitialized
        case insertionFailed
    }
   ...
}

However I hold getting Error: An exception occurred whereas batch inserting the Clock Copy path information information. Error particulars: unacceptableStatusCode(404) Didn't ship information to Supabase: unacceptableStatusCode(404).

I do know that my url and my API key are appropriate.

Credit: www.ismmailgsm.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button