Search code examples
iosibeaconappdelegate

iBeacon-App: Custom code when launched from lockscreen


Since iOS 8, the operating system is indicating an iBeacon-enabled application, which is inside a defined region, with an icon in the left bottom corner of the lockscreen (see http://appleinsider.com/articles/14/06/03/apples-ios-8-uses-ibeacon-tech-brings-location-aware-app-access-to-lock-screen for reference).

I want to make use of this feature in my app by running custom code if the app is launched from the lockscreen (e.g. switch to specific view).

How to check in the Application Delegate if the app was launched from the lockscreen? I couldn't find any documentation on this.


Solution

  • AFAIK, it's not possible to detect whether your app was brought into the foreground via the "Suggested apps" feature (that's what Apple calls the icon on the lock screen), or by any other means (app switcher, app icon on the home screen).

    You could do some heuristics. If the app came into the foreground and there are no beacons in range (you can check that with ranging), then there's no way it was via the lock screen icon.