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 MainActor.run {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
}
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