Detect when a notification appears (from another application) to change my layout - ios

Do I want to know if it's possible to detect when a notification from another application is over my app? For example, when the user receives an SMS or Messenger message. Detect the fact that a notification is present on the screen. I don't want the content of the message.
It's an example, It can be a notification for whatever. Because, when a notification is visible, my player's lost because a part of the UI is under the notification. So, if I know when a notification is visible I can change the layout.

It's not possible to handle notifications from other apps. It would be a huge privacy violation.

Related

Swift iOS system notification dismiss calback

Question:
Is there a way to detect if you get a system notification and you swipe away the notification banner (e.g. the alarm that triggers a system notification)?
More practical example:
In your app, you are doing some stuff and suddenly you get a notification from another app. Instead of tapping on the notification, you swipe up the notification (you dismiss it that way). After doing that, I want to capture that in the app.
Why:
Currently, I have a bug in the app, so if I can capture this action, I would be able to fix this bug.
Thanks in advance!
When notification appears, the willResignActiveNotification won't get called, therefore willEnterForegroundNotification won't get called, too.
The best solution here is to catch incoming notification and show the custom view describing this notification instead of system one. Thus, you can detect all actions/timings you need.

iOS Push Notification with Rich Content - Can I prevent a notification from being tappable?

I have a push notification with rich content.
Can I make it in such way that it is not tappable, i.e., a single tap will not open the application. It must be dragged down to rich content or 3D touched, or deleted from the notification center by swiping.
How should I indicate to the user to drag down (3D touch) in order to reveal rich content on notification?
No, a tap on a push notification will always open the notification in the app, and as far as I know there is no way in public API to override this behavior. It does appear there is a private API to get the behavior you’re looking for, as some iOS-generated (local, not push) notifications appear to do exactly what you’re asking. If you can manage to uncover that, use at your own risk should Apple find out.
Now, as for possible solutions: I would consider implementing code on your app’s delegate to respond appropriately when the notification is opened. For example, send the user to an appropriate location in the app when the app is launched from a notification…perhaps a view controller that shows the same content that would be shown as the rich notification content. I don’t know the exact use case, but the wording implies to me that if the app launches to its main interface, it could be confusing to a user.
It’s impossible for me to tell you how exactly you wish to respond to notifications, so for more on responding appropriately when the app was launched from a push notification, see the following documentation from Apple:
Determine Why Your App Was Launched
UIApplicationDelegate.application(_:willFinishLaunchingWithOptions:)
UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:)
UIApplication.LaunchOptionsKey
UIApplication.LaunchOptionsKey.remoteNotification
Hopefully from that you can find a suitable solution. But if that isn’t an option, consider directly telling the user at some point to press firmly (or tap and hold, as many devices do not support 3D Touch) to view the content. You could do this during some onboarding process or, as an absolute last resort, in the notification itself.
Before proceeding down that route, though, understand that not all users know 3D Touch and/or this rich-content functionality even exists — even fewer use it regularly — and if they become confused, they may decide to clear the notification or outright disable your app’s notifications. In general, it’s also a bad idea to “teach” your user unfamiliar ways of using their device. If a user is used to tapping on notifications, as many are, they will most likely tap on your notifications. It can be tough to break that muscle memory.

Keeping notifications in panel until user taps them

I've noticed that when a user receives a push notification, if he taps it from the notification panel (or manually launches the app, for that matter), it'll remove the notification from the panel. I suppose this is fine if it's a single notification, but what about if the user has multiple notifications? I wouldn't want it to clear all of them, just the one that was tapped.
I've been having trouble finding out information on this. I know it MUST be possible, because the Skype app does it. You receive 5 push notifications about unread messages on Skype, and if you tap one, it launches the app. However, it doesn't remove all the notifications from the panel, only the one you tapped. How are they doing this?

Distinguish notification center hiding and returning from background with DidBecomeActive notification

I'm confused about UIApplicationDidBecomeActiveNotification. I can register an observer for this notification, and receive signals when the app becomes active from the background or when being launched. However, when I pull down the hidden top popup view (for general information: notifications, weather, stock market) then pull up to hide it, the signal is also generated.
I use a callback method hooked with this signal to refresh my app, so this can be annoying for users of my app.
Can anybody help me differentiate these cases?
Maybe you should try UIApplicationWillEnterForegroundNotification, the apple doc has said:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html
UIApplicationDidBecomeActiveNotification: Posted when the application becomes active.
An application is active when it is receiving events. An active application can be said to have focus. It gains focus after being launched, loses focus when an overlay window pops up or when the device is locked, and gains focus when the device is unlocked.

IOS Is there a way to send user to particular view after tapping "view" on notification?

I am using push notifications in my app and I would like to send user to particular view, not the view he last saw. Is it possible?
You need to implement the appropriate AppDelegate messages.
Specifically, you will receive the APNS payload on the application:didFinishLaunchingWithOptions:
You might also receive the payload in a different message, application:didReceiveRemoteNotification: if the application is active.
Then when you know that your app was launched because the user touched a notification, you can direct him to a specific view accordingly.
I don't think that you have control over what the user sees while app is starting app (opening animation). After the app is fully active, you can send him wherever you want to by opening proper view controllers, setting proper tab, etc...

Resources