How to use MainActor with Continuation?

I have decided to wrap the app delegate method's for remote notifications with Continuation and I have created the following method

func fetchDeviceToken() async throws -> String {                
        return try await withCheckedThrowingContinuation { continuation in
            self.activeContinuation = continuation
            Task {
                await {

My understanding is that within the withCheckedThrowingContinuation closure, we should call the method for the listener to start getting the events

once UIApplication.shared.registerForRemoteNotifications() gets called, the delegate calls the activeContinuation but its nil to the context switching within withCheckedThrowingContinuation

As I look at it more, we should assign the continuation first then call the method that will trigger the listening of those events, am I sort of in the right direction?

Terms of Service

Privacy Policy

Cookie Policy