Gibt es eine Möglichkeit zu überprüfen, ob das iOS-Gerät gesperrt/entsperrt?

Habe ich verwendet GPS-Standort-updates in meiner Anwendung. Ich möchte erkennen, wenn das iOS-Gerät ist im sleep Modus, so kann ich deaktivieren Sie die GPS-Position aktualisiert und die Optimierung der Akku-Nutzung. Ich habe bereits versucht pausesLocationupdates in iOS 6, aber es funktioniert nicht wie gewünscht.
Ich möchte abschalten die GPS-Position aktualisiert, sobald das Gerät geht in den sleep-Modus.
Ich will erkennen, die lock/unlock-Ereignis in das Gerät.

Gibt es eine Möglichkeit, diese Funktionalität zu erreichen ?

bisher hab ich die darwin-Meldungen wie unten angegeben

-(void)registerForall
{
    //Screen lock notifications
    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
                                    NULL, //observer
                                    displayStatusChanged, //callback
                                    CFSTR("com.apple.iokit.hid.displayStatus"), //event name
                                    NULL, //object
                                    CFNotificationSuspensionBehaviorDeliverImmediately);


    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
                                    NULL, //observer
                                    displayStatusChanged, //callback
                                    CFSTR("com.apple.springboard.lockstate"), //event name
                                    NULL, //object
                                    CFNotificationSuspensionBehaviorDeliverImmediately);

    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
                                    NULL, //observer
                                    displayStatusChanged, //callback
                                    CFSTR("com.apple.springboard.hasBlankedScreen"), //event name
                                    NULL, //object
                                    CFNotificationSuspensionBehaviorDeliverImmediately);

    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
                                    NULL, //observer
                                    displayStatusChanged, //callback
                                    CFSTR("com.apple.springboard.lockcomplete"), //event name
                                    NULL, //object
                                    CFNotificationSuspensionBehaviorDeliverImmediately);

}
//call back
static void displayStatusChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
    NSLog(@"IN Display status changed");
    NSLog(@"Darwin notification NAME = %@",name);


}

Ich bin in der Lage zu Holen Sie sich die darwin-Benachrichtigungen, wenn das Gerät gesperrt/entsperrt, aber das eigentliche problem ist, wie identifizieren zwischen, wenn die Meldung gekommen ist, zu sperren oder entsperren des Geräts. Konsole-Protokolle sind:

 LockDetectDemo[2086] <Warning>: IN Display status changed
 LockDetectDemo[2086] <Warning>: Darwin notification NAME = com.apple.springboard.lockcomplete
 LockDetectDemo[2086] <Warning>: IN Display status changed
 LockDetectDemo[2086] <Warning>: Darwin notification NAME = com.apple.springboard.lockstate
 LockDetectDemo[2086] <Warning>: IN Display status changed
 LockDetectDemo[2086] <Warning>: Darwin notification NAME = com.apple.springboard.hasBlankedScreen
 LockDetectDemo[2086] <Warning>: IN Display status changed
 LockDetectDemo[2086] <Warning>: Darwin notification NAME = com.apple.iokit.hid.displayStatus

Alle privaten API würde auch ausreichen.
Vielen Dank im Voraus.

Sie können versuchen, und verwenden Sie ein Beobachter auf UIApplication.shared.isProtectedDataAvailable wird wieder true wenn das Gerät entsperrt ist

InformationsquelleAutor Rohit Kashyap | 2013-01-09

Schreibe einen Kommentar