ios – Why does the applicationState writer solely publish as soon as?


I wish to react each time the applying state adjustments. I am listening to the .applicationState writer:

UIApplication.shared.writer(for: .applicationState)
  .subscribe(on: DispatchQueue.predominant)
  .sink(receiveCompletion: { completion in
    change completion {
    case .completed:
      print("completed")
    case .failure:
      print("failure")
    }
  }, receiveValue: { state in
    print("state", state.rawValue)
  })
  .retailer(in: &cancellables)

Nonetheless, this solely fires as soon as (however does not full). If I background the app and reopen it, it does not publish any new values. Why?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles