Post

Replies

Boosts

Views

Activity

PushKit Voip notifications not triggering CallKit UI in the background
I am trying to add voip call functionality to my app. It works as expected while the app is in the foreground. But in the background it does not. I have registered the app as requiring background voip permissions. My implementation doesn't fit into one of these posts, so here is a gist: https://gist.github.com/BrentMifsud/4be43c022c1279f04ecb56250a86b3f1
0
0
310
Jan ’25
Ensuring exclusive access to a function in structured concurrency
So our back end manages tokens in a strange way. Whenever we try to request a new access token using our refresh token, it invalidates our old refresh token and returns us with a new access + refresh token. The problem with this is that multiple concurrent network requests can see that a user's access token has expired and try to get a new access token, potentially causing us to get a 401 unauthorized error. Is there any way with structured/unstructured concurrency to ensure that our method for grabbing the access token can only at max be run once at a time? Im assuming the only realistic way would be to do something like this: @MyGlobalActor private var tokenTask: Task<String, any Error>? @MyGlobalActor func getAccessToken() async await -> String { if let tokenTask { return try await tokenTask.value } self.tokenTask = Task<String, any Error> { // refresh access token } let token = try await self.tokenTask!.value self.tokenTask = nil return token }
1
0
504
May ’24