All of these came from just one app I'm currently developing, let's call this app SampleApp
How do I get a list of these notifications from my Phone's Tray
Yes I do know that I may be able to get the notifications via this code
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().getPendingNotificationRequests { (requests) in
print("here are the iOS 10 notifs \(requests)")
}
} else {
let requests = (UIApplication.shared.scheduledLocalNotifications ?? [])
print("here are the NON iOS 10 notifs \(requests)")
}
But the problem with this code is that I can only get notifications which I created offline, and not those coming from the Apple Push Notification Server (APNS)
By created offline I mean, scheduled UILocalNotification
s, and since Push Notifications aren't UILocalNotification
s I have no idea what to do
Some Questions You May ask
Are these notifications from my app?
Am I using the didReceiveRemoteNotification
on the AppDelegate
?
Does my remote notifications work/come from APNS
What does my code for registering remote notifications look like?
if #available(iOS 10.0, *) {
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: authOptions, completionHandler: { (_, _) in })
} else {
let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
To find your notifications, from the top of your phone screen, swipe down. Touch and hold the notification, and then tap Settings . Choose your settings: To turn off all notifications, turn off All notifications.
Once you're in the Settings app, tap Notifications. In the resulting screen (Figure 1), tap Notifications. Accessing the Notification History in Android 12. In the next window (Figure 2), enable the Notification History by tapping the On/Off slider until it's in the On position.
To see your notifications in Notification Center, do any of the following: On the Lock Screen: Swipe up from the middle of the screen. On other screens: Swipe down from the top center. Then you can scroll up to see older notifications, if there are any.
You can fix an iPhone that's not getting notifications by restarting it or making sure notifications are turned on. You should also make sure your iPhone is connected to the internet so apps can receive notifications. If all else fails, you should try resetting the iPhone — just make sure to back it up first.
Dávid Pásztor's comment partially solved the issue because now I can retrieve the all (push and non push) Notifications displayed in the Notification Center, but only for iOS 10
because the code below is only for iOS 10
devices and above, what about other versions?
UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in
print(notifications)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With