How can I tell if a user opened my iOS app from the home screen icon (without 3D touch)? - ios

How can I tell if a user used the icon from the home screen? (as opposed to from a notification, for example)
application(_:didFinishLaunchingWithOptions:) signals the initial launch, but has no way to indicate whether it was opened from the home screen icon or opened from the app switcher after being terminated by the OS.
application(_:performActionFor:completionHandler:) is only for 3D touch actions.
applicationWillEnterForeground(_:) is better than applicationDidBecomeActive(_:) since it doesn't get called after opening the UI Notification Center, but still can be called for other reasons.

Related

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

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

iOS 10 local notifications: show notification content on lock screen

I've added local notification with Notification Content Extension.
It shows okay on home screen (with app in background).
The problem lies in displaying notification content on lock screen. When notification arrives on lock screen, it is only displayed with text and swiping left shows "Clear" button.
I need some way to show notification fully from lock screen (as on home screen).
For example I saw "View" button in some of the tutorials/articles, can I even create or control something like it?
So with notifications on iOS 10, Apple changed the way they appear on devices. When the screen is locked, you can see a View and Clear button or just clear button based on whether the device is enabled with 3D touch or not.
Swiping left on a message now offers View and Clear on non-3D Touch devices or just Clear on 3D Touch devices.
On 3D Touch devices, the long press on notification reveals the notification actions menu which can be customized using Category definition in the code.
Hope this answers your query.

Can I make my iphone app use only a portion of the screen

I was hoping to create a small windowed screen when the home button is pressed. It would keep a portion of the app process open while another app isn't open.
So say I had music playing on the app and when the home button gets pressed the screen would be windowed or shrunk and just displayed over the main screen (kind of like the little help button that can be moved around). Would using widgets in IOS 8 work?
When the user presses the Home button, the app goes to background, and that's it. You can't customize that action.
You only get a notification that the user closed the app so that you can save your app state or data for the next launch.

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.

How to identify if a user has locked the screen in an iOS 5 app

Our iOS app has its own passcode screen which is displayed to the user each time the application loads.
An additional requirement is that the passcode screen should be displayed if the user locks the screen. Initially I have used the applicationWillResignActive method within the app delegate to set the passcode view as a modal. I'm setting it on resign rather than applicationDidBecomeActive so that when iOS makes our app visible again you don't see a quick switch between views.
This works fine for when the user locks the screen but resignActive is also called when an SMS alert is recieved, which means that even if the user dismisses the notification they are asked to enter their passcode again.
Is there a way to work out if the screen has been locked, so I can respond specifically to that event?

Resources