복사성공!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
NotificationCenter.default.addObserver(
self,
selector: #selector(willResignActive(_:)),
name: UIApplication.willResignActiveNotification,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(didBecomeActive(_:)),
name: UIApplication.didBecomeActiveNotification,
object: nil
)
func willResignActive(_ notification: Notification) {
// 연결 종료
NuguCentralManager.shared.stopReceiveServerInitiatedDirective()
}
func didBecomeActive(_ notification: Notification) {
// 재연결
NuguCentralManager.shared.startReceiveServerInitiatedDirective()
}