Monitor content displayed on iPhone's screen - ios

I want to monitor the iPhone's screen in background, whenever the content displayed on the phone window was changed, the app will send out a notification.
For example, if I open Stack Overflow in Safari, when the page is loading or some Flash on the page is animating, I will receive the notification. But I don't know how to detect the event.

Related

Open unlock screen when displaying notification content extension

In my iOS/iPadOS app I have notification content extension, which presents extended content in WKWebView. However, when started on lock screen, WKWebView does not load data properly. Therefore, I would like to ask user to unlock the device before displaying content. This is how Apple Mail does that - when selecting (long-pressing) notification banner on lock screen, it presents unlock screen (Passcode screen) before displaying content.
Question:
Do you know, how to do that? Is there any API to present unlock screen programmatically?

Is there a way to have an app notification to be persistent in iOS?

We have a requirement to create a notification that stays on screen for the period of the event. Every time user clicks on it, it should navigate to the app, but notification remains on the lock screen/notification screen.
Is it possible in iOS?

Notification/Widget on lock screen with button in Swift

I have an app that contains stopwatch and when time is running and the app enters background I would like to have a notification on lock screen and in Notification Center (when you swipe down). The notification should contain actual time of the stopwatches and user should be able to stop/start the stopwatches.
I was trying to achieve this using UNNotificationContentExtension but as documentation says:
When an iOS device receives a notification containing an alert, the system displays the contents of the alert in two stages. Initially, it displays an abbreviated banner with the title, subtitle, and two to four lines of body text from the notification. If the user presses the abbreviated banner, iOS displays the full notification interface, including any notification-related actions. The system provides the interface for the abbreviated banner, but you can customize the full interface using a notification content app extension.
I found out that I am able to edit just full notification interface which means that when user gets notification and opens it I can show him whatever I want (I tried mediaPlayPauseButtonType to handle stopwatches). But when I check the lockscreen the notification stays default.
What are the possibilities to achieve Notification similar to Spotify - when you play song, you can pause the song and you can see the time etc. from the lockscreen?
Thanks!

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

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.

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.

Resources