Swift Xcode - how to differentiate between going to lock screen and going to home screen? - ios

When the app enters the background or WillResignActive, both functions are called in my SceneDelegate. How am I able to distinguish between when the user exits the app to the HomeScreen versus just locking their phone?
EDIT: I want to perform a different function in each scenario

Related

How to detect if the app was minimized IOS

I'm fairly new to ios development. I'm actually coming from Flutter and have to make these native calls myself.
Basically, my app runs a timer/countdown (5-10mins). If the user minimises the app I want to stop the timer (e.g. user starts doing something else with the phone). If the user, however, simply locks their screen, I want the timer to continue.
I tried using some of the lifecycle calls like applicationDidEnterBackground and applicationWillTerminate, however, it seems both are called for minimization and screen off. How do I do it?

ApplicationShortcuts, is there any way to not open the app and only execute some actions such as Play/Pause?

I have an audio app and I want to control play/pause with ApplicationShortcutItem directly, but I don't want to open the app.
Is it possible?
It is not possible to leave an app in the background when choosing a Home screen quick action.
From the documentation of UIApplicationShortcutItem:
When a user chooses one of your Home screen quick actions, the system launches or resumes your app and UIKit calls the application(_:performActionFor:completionHandler:) method in your app delegate.

How to create iPhone app without user operation in response to the iBeacon detection

Is it possible the following behaviors on my iPhone app ?
1) Proccess begins in background ,when detecting iBeacon wave.
2) Proccess begins with a screen, when detecting iBeacon wave, but
the application will finish automatically(without any user operations) after proseccing.
To simply put it, no. In order for your code to execute in the first place, the user needs to tap on the app. That sort of style application MAY be able to work on Android, but not on iPhone.
You CANNOT start an application from the background.
Also, when it's in the background, you CANNOT bring its UI up and obstruct what the user's trying to do.

How to tell when user interacts with iOS location-aware lock screen app icon

My app uses location services in the background and as a result it shows on the iOS 8 lock screen (see picture). Is there any way to tell when an app is brought to the foreground by the user sliding this button?
The app will necessarily be launched when this button appears -- since it's being awakened by the same location signal that is causing it to appear on the lock screen. Accordingly, application:didFinishLaunchingWithOptions: has a launch options dict with UIApplicationLaunchOptionsLocationKey = 1.
That's useful, but what I want to know is when the app is brought to the foreground due to interaction with the button. No relevant application delegate methods seem to be called in this case, except didBecomeActive: and didMoveToForeground: but these methods don't carry extra data.

Can I figure out in iOS whether the app is resuming from standby or from multitasking

I'm currently working on a change request for our iPad app that requires that I handle the resuming of the app in two different ways depending on whether the app returned from multitasking (the user was active in another app or on the homescreen and came back to the app) and standby (the iPad was switched to standby either through the standby button on top or by closing the Smart Cover)
In both cases the following methods are called in my AppDelegate:
applicationWillResignActive followed by applicationDidEnterBackground when I hit the homebutton to get tot he home screen or close the Smart Cover
applicationWillEnterForeground and applicationDidBecomeActive when I come back.
As the same methods are called I am a bit lost on how to detect where I come from on resume. All four methods have a single parameter passing in the UIApplication. I looked at its interface, but didn't find any useful clues.
Is there a way to differentiate between resuming from multitasking or standby?
There is no public api method to define why application did become active

Resources