How to detect when the control/notification center appears? - ios

In my iOS app I want to know when the control or the notification center appears. Is there a notification specifically for this available? The notifications for applicationWillResignActive and applicationDidBecomeActive do not help in my situation because they are not specific enough.

Related

How to prevent an iOS notification being removed from the Notification Center when tapped

Is there a way to prevent a remote notification in the Notification Center from being removed by the OS after it is tapped by the user? The tap invokes the app and didReceiveNotificationResponse() is called. I am not using badges in the notifications.
Apple is not allowing to persist the notification once after you open it.
What’s next
You can create a local notification from data you get from push notification when user taps on it. I have not tried the implementation but it should work in your usecase.
User will not be knowing whether it is local or push notification.

iOS Notification or Control center displayer event

In my app I need to know when Notification or Control center are displayed (I'm displaying some information when app goes to background). In my AppDelegate I "listen" to events like when app goes to background, etc... I workd for all cases....except for Notification or Control center. It is very weird that AppDelegate receives "applicationDidBecomeActive" event when Notification center is displayed. Control center works like it should btw. That makes no sense to me.
Anybody have solution/info regarding this?

UI-Test with XCTest: how to trigger App-State Foreground-Inactive Foreground-Active

How can I trigger the following behavior in Swift UI Tests via XCTest:
Get the app to foreground and inactive (applicationWillResignActive) and back to "foreground and active" (applicationDidBecomeActive)
Possible gestures, while app is in foreground and active, could be:
open app switcher and go back to app
open control center and hide control center
open notification center and hide notification center
I searched for something like that following fictive(!) code XCUIDevice.shared.doublePress(XCUIDevice.Button.home) or XCUIDevice.shared.swipeDownFromOutside(); XCUIDevice.shared.swipeUpFromOutside().
Or a more better way a method call to simulate an open app switcher, control center or notification center immediately.
Or in the best way to simulate the status applicationWillResignActive, applicationDidBecomeActive immediately.
Important to understand: the event applicationDidEnterBackground must not called - the app has to stay in foreground (but inactive)!
So recently on wwdc2017 Apple released a convenient way to work with multi app. You can see the multi App portion of the video link below.
https://developer.apple.com/videos/play/wwdc2017/409/

Notification should stay

I have my application developed on iOS 8 . I have implemented push notification in my application. In iOS 8 clicking on notification automatically clears that particular notification. But my requirement is notification should stay until clear manually. Please give suggestion how to achieve this.
This is a system behavior. You can not prevent this to happen.
If you need something to be always visible from the notification center, consider to create a Notification Center Widget.

iOS Display local notifications pop-up while in background

I'm having a little problem in my app : I use to send local notifications to the user when actions are performed in my app, while it's running in background. Notifications are displayed perfectly in the notification center, but there is no pop-up when the notification occurs.
If I'm right, apps running in foreground can't display pop-up on the user screen (only in the notification center) but when the app is running in background, in fact there is pop-up displayed automatically ?
Thanks for your help !
EDIT : In fact, I'm speaking about a notification banner to be displayed too when the notification appear in the notification center.
When your app will go in background then you will see an immediate notification on your phone but you have to tap that notification to trigger didReceiveLocalNotification delegate.
If you receive local notification in foreground then didReceiveLocalNotification will be triggered automatically.
Above scenario is tested and verified.
Update: You must read this documentation: http://www.thekspace.com/home/component/content/article/62-uilocalnotification-demystified.html

Resources