简体   繁体   中英

How to Identify the specific event, when user has locked/unlocked the iPhone5 device?

I have gone through many questions, but didn't get exactly how I'll get the lock/unlock event for iOS 5 and above.

From the various post, I understood that when user locks the screen in iOS 5 iPhone, socket connection is lost and for that we need to handle network connectivity part in background method beginBackgroundTaskWithExpirationHandler .

But is there an exact way to handle specifically lock/unlock event on iOS? Because applicationWillResignActive method is called for screen locking/unlocking and other events, like exiting application by pressing home button or launching another application.

Is there any specific delegate method called only when iPhone screen is locked/unlocked?

No, there's no way of distinguishing in general why your app transitions to the background. There are some ways to detect, say, a phone call ( CTCallCenter in the Core Telephony framework), but there's no way to tell that the device is locked specifically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM