Skip to content

Releases: convex/convex-swift

Convex for Swift 0.8.2

Choose a tag to compare

@dowski dowski released this 29 Oct 20:22

This is a bug fix release.

  • Includes a fix for a #21 - auth operations are now serialized and can't lead to bad state and subsequent crashes

Convex for Swift 0.8.1

Choose a tag to compare

@dowski dowski released this 20 Feb 15:26

This is a bug fix release.

  • Includes a fix for a crash that can happen if cancel() is called on a subscription that was already terminated (convex/convex-mobile@59081a7)

Convex for Swift 0.8.0

Choose a tag to compare

@dowski dowski released this 17 Feb 22:38

This is a minor feature release with improvements to the auth lifecycle and some bug fixes.

The AuthProvider interface was updated to allow providers to push refreshed tokens into the ConvexClientWithAuth. That allows apps to remain authenticated while the provider keeps the tokens fresh. This is a breaking change that will require existing AuthProvider implementations to be updated.

At a minimum the login and loginFromCache methods on an AuthProvider will need to be updated to accept a new onIdToken callback. If the provider supports background refresh, that callback should be called with a new JWT ID token when a refresh happens.

public class MyProvider: AuthProvider {

  public func login(onIdToken: @escaping @Sendable (String?) -> Void) async throws -> AuthData {
    ...
  }

  public func loginFromCache(onIdToken: @escaping @Sendable (String?) -> Void) async throws -> AuthData {
    ...
  }
}

The loginFromCache method will also be called by the client when a WebSocket reconnect happens, allowing AuthProvider instances the chance to provide a new token if one expired while an app was suspended or offline for some period of time.

A related bug in the Rust client was fixed that prevented reliable re-auth after reconnect.

Finally, JSON decode errors (e.g. on data missing for Decodable struct) will throw/return an error rather than crash the app. It's up to app developers to choose how to handle an error like that (degrade gracefully in some way or trigger a crash) when calling a mutation/action or consuming a query subscription.

Thanks to @seanperez29 for contributing some of the auth changes in this release.

Convex for Swift 0.7.0

Choose a tag to compare

@dowski dowski released this 04 Dec 03:30

This is a minor feature release.

It includes a new API to observe the state of the underlying WebSocket connection to the Convex backend.

Here's a small example showing how to use watchWebSocketState() - it changes the color of an icon from blue to red depending on whether the WebSocket is connected or connecting. The Convex client will always try and connect the WebSocket so it will always be in one of those two states.

import SwiftUI
import ConvexMobile
internal import Combine

let convex = ConvexClient(deploymentUrl: "$URL")

struct ContentView: View {
  @State private var isConnected: Bool = false
  
  var body: some View {
    VStack {
      Image(systemName: "globe")
        .imageScale(.large)
        .foregroundStyle(isConnected ? (Color.blue) : Color.red)
    }
    .task {
      for await value: WebSocketState in convex.watchWebSocketState().values {
        switch value {
	        case .connected:
	          isConnected = true
	        case .connecting:
	          isConnected = false
        }
      }
    }
    .padding()
  }
}

Convex for Swift 0.6.1

Choose a tag to compare

@dowski dowski released this 20 Nov 04:13

This is a bug fix release.

Includes a dependency on an updated version of convex-rs with a fix for a deadlock.

convex/convex-rs@8d500d0

Prior to this version, applications receiving rapid query updates while sending outgoing requests could experience the ConvexClient becoming unresponsive.

Convex for Swift 0.6.0

Choose a tag to compare

@dowski dowski released this 31 Oct 01:42

This is a minor feature addition release.

There's a new initConvexLogging method which will surface Convex client logs in OSLog. This should give developers greater visibility into the state of the Convex client throughout the lifecycle of their applications. Example usage:

import SwiftUI
import ConvexMobile

@main
struct SampleApp: App {
  init() {
    // After this call, use of ConvexClient elsewhere in the app will generate logs.
    initConvexLogging()
  }
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}