iOS how to detect user has changed system time, and if not compare device time with server time

前端 未结 4 1362
名媛妹妹
名媛妹妹 2021-01-01 01:22

The requirement is that have to detect if the system time of iPhone is changed by user manually. For that I have used

NSNotificationCenter.defaultCenter         


        
4条回答
  •  醉梦人生
    2021-01-01 02:02

        This code worked for me in Swift 3
    
        NotificationCenter.default.addObserver(self, selector: #selector(ClassName.timeChangedNotification), name: NSNotification.Name.NSSystemClockDidChange, object: nil)
        }
    
        // Method get called user changed the system time manually.
    
        func timeChangedNotification(notification:NSNotification){
            print("Device time has been changed...")
        }
    

提交回复
热议问题