-2

I am using push notifications in my application using Firebase.

How do we know whether or not the user has enabled the notification service in his settings for our app?

jkdev
  • 11,360
  • 15
  • 54
  • 77
srik nth
  • 1
  • 5
  • https://stackoverflow.com/questions/40531103/swift-ios-check-if-remote-push-notifications-are-enabled-in-ios9-and-ios10 possible duplicate? – Alexandr Kolesnik Jul 24 '19 at 05:02
  • Possible duplicate of [Swift ios check if remote push notifications are enabled in ios9 and ios10](https://stackoverflow.com/questions/40531103/swift-ios-check-if-remote-push-notifications-are-enabled-in-ios9-and-ios10) – RajeshKumar R Jul 24 '19 at 05:22

2 Answers2

0

As far as I know, there's no way you can alter push notification on the client-side, unless you can make sure the app is running so you can filter out the notification.

But you can do some workaround on your backend. You can collect all the client token on your backend, and save whether the client is turning the push notification on or off. In this way, you can send the push notification only for the client who has enabled push notification.

jkdev
  • 11,360
  • 15
  • 54
  • 77
Wendy Liga
  • 634
  • 5
  • 12
  • Actually we are proving sms messages and notifications , I want to which users are enable the notifications I disable the sms service to him for overcoming of duplicity that purpose only. – srik nth Jul 24 '19 at 04:33
  • How to I know user is enable or not for notifications for saving purpose only. – srik nth Jul 24 '19 at 04:35
  • 1
    if you mean, knowing notification access is granted by user, you can check that by here https://stackoverflow.com/questions/46457733/how-to-get-notification-authorization-status-in-swift-3 the tricky part is, you can only access this value only when app is running on foreground – Wendy Liga Jul 25 '19 at 03:02
0

You can know the Notification settings of the app by using the below code.

UNUserNotificationCenter.current().getNotificationSettings { settings in

  print(settings.authorizationStatus.rawValue)

}

settings has whole lot of information about the notification permission of the app. Please find the Apple document here

Anand
  • 1,820
  • 2
  • 18
  • 25