7

I am trying to find device lock state as UIApplicationState gives the wrong state when Lock the device, it gives UIApplicationStateActive for few second.

I found one solution using Darwin notifications for notification "com.apple.springboard.lockcomplete".

Is it the correct way to get Lock state? Does Apple allow this?

Santosh Singh
  • 765
  • 11
  • 27
  • 3
    You shouldn't be allowed to listen to the device lock state. Apple may reject your app for that. – Larme Sep 12 '16 at 11:36
  • 1
    Possible duplicate of [Is there a way to check if the iOS device is locked/unlocked?](http://stackoverflow.com/questions/14229955/is-there-a-way-to-check-if-the-ios-device-is-locked-unlocked) – M_G Sep 12 '16 at 11:41
  • Larme, Thanks for your reply, can you please tell some apple link that explains it as the hackish solution? – Santosh Singh Sep 12 '16 at 11:47
  • 1
    what is wring with the `UIApplicationDidEnterBackgroundNotification`? is there any _hidden_ reason why the app must know about the user locks the device? – holex Sep 12 '16 at 14:43
  • 1
    When you observe notification UIApplicationDidEnterBackgroundNotification , it gives state as UIApplicationStateActive whereas it should give UIApplicationStateInactive or UIApplicationStateBackground. – Santosh Singh Sep 12 '16 at 15:20
  • I think you can use these notifications because if Darwin notification come under private APIs then Apple reject your app even in Testflight.My app is working fine in Testflight.So I hope it will go through. – Desert Rose Sep 13 '16 at 13:10
  • 1
    I am quite afraid as it is private notification. No proper documentation available. – Santosh Singh Sep 14 '16 at 09:02
  • 3
    Apple no longer allows this. https://forums.developer.apple.com/message/224401#224401 – Rhythmic Fistman Apr 21 '17 at 04:07
  • @SantoshSingh how did it go? did Apple let the code thru? – Roman Kozak Sep 24 '21 at 13:35

4 Answers4

6

No Apple won't allow to use "com.apple.springboard.lockcomplete".My application get rejected due to this.

V V
  • 774
  • 1
  • 9
  • 29
2

The answer is... it depends.

Using non-public API is not permitted, and these Darwin notifications are not publicly documented. So the official answer is no, you are not allowed to use this notification in a production code. Otherwise, you risk getting this unpleasant email from Apple:

Your app uses or references the following non-public APIs: com.apple.springboard.lockcomplete

On the other hand, I've used that very notification for 4 years till I got a rejection from the App Store for one of my apps. Another app of mine still uses it without problems. So if you really need it and you think it's worth the risk, you may give it a try.

Vladimir Grigorov
  • 10,903
  • 8
  • 60
  • 70
2

Based on our experience, your app WILL be rejected for use of com.apple.springboard.lockcomplete with the following notification:

Guideline 2.5.1 - Performance - Software Requirements

Your app uses or references the following non-public APIs:

com.apple.springboard.lockcomplete

The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.

Continuing to use or conceal non-public APIs in future submissions of this app may result in the termination of your Apple Developer account, as well as removal of all associated apps from the App Store.

Next Steps

If you are using third-party libraries, please update to the most recent version of those libraries. If you do not have access to the libraries' source, you may be able to search the compiled binary using the "strings" or "otool" command line tools. The "strings" tool can output a list of the methods that the library calls and "otool -ov" will output the Objective-C class structures and their defined methods. These tools can help you narrow down where the problematic code resides. You could also use the "nm" tool to verify if any third-party libraries are calling these APIs.

Resources

If there are no alternatives for providing the functionality your app requires, you can file an enhancement request.

0

Apple won't allow this.Here is there comments for this "The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.

Continuing to use or conceal non-public APIs in future submissions of this app may result in the termination of your Apple Developer account, as well as removal of all associated apps from the App Store."

Hula
  • 51
  • 3