Hey guys,
My iOS application has an extension that detects device Unlock and Lock event. I found 2 separate API to detect. Both of them work great.
But my code is rejected twice by Apple Review Team. The following reason was to reject our binary.
From Apple
Guideline 2.5.1 - Performance - Software Requirements
Your app uses or references the following non-public APIs:
com.apple.springboard.lockcomplete
com.apple.springboard.lockstate
1. First solution to detect device lock and unlock
-----------------------------------Code Starts here-----------------------------------
#import <notify.h>
int notify_token;
notify_register_dispatch("com.apple.springboard.lockstate",
¬ify_token,
dispatch_get_main_queue(),
^(int token)
{
uint64_t state = UINT64_MAX;
notify_get_state(token, &state);
if(state == 0) {
self->lastActiveDate = [NSDate date];
self->deviceCurrentState = _DEVICE_LOCK_STATE_UNLOCKED;
} else {
self->deviceCurrentState = _DEVICE_LOCK_STATE_LOCKED;
}
}
);
-----------------------------------End of Code-----------------------------------
2. Second solution to detect device lock and unlock
-----------------------------------Code Starts here-----------------------------------
-
(void)registerforDeviceLockNotif
{
//Screen lock notifications
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
CFBridgingRetain(self), // observer
displayStatusChanged, // callback
CFSTR("com.apple.springboard.lockcomplete"), // event name
NULL, // object
CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
CFBridgingRetain(self), // observer
displayStatusChanged, // callback
CFSTR("com.apple.springboard.lockstate"), // event name
NULL, // object
CFNotificationSuspensionBehaviorDeliverImmediately);
}
- (void)removeDeviceLockNotif
{
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), CFBridgingRetain(self), CFSTR("com.apple.springboard.lockstate"), nil);
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), CFBridgingRetain(self), CFSTR("com.apple.springboard.lockcomplete"), nil);
}
-----------------------------------End of Code-----------------------------------
Since we are unable above 2 part of codes, what solution or what API we would use to detect device lock and unlock events?
Thank you.