I am enabling push notification for my application. How can we read the flags for notification in “Settings” app when my app is Running. For some reasons, I need to know whether a particular notification (alert, sound, badge) is set to ON/OFF.
Please guide.
Try evoking this method
[[UIApplication sharedApplication] enabledRemoteNotificationTypes]It will return a UIRemoteNotificationType which you can work with to determine what is available.
Now, status can be looked at as an int using
NSLog(@"status = ", status);, to which we can determine exactly what is on. But to do this we need to understand UIRemoteNotificationType.Without going into much detail, what you basically need to walk away from this knowing is that …
Let’s say you want to know if badges/sound/alerts are all on. The UIRemoteNotificationType (status if you are playing along) should come out to be 7.
Now, lets work backwards. Lets say that
status == 5. There is only one configuration of settings that can give us this value, and that is if badges and alerts are on (badges add 1, alerts add 4, total is 5) and sound is off.What if
status == 6? Again, there is only one configuration of settings that will return this number, and that is if alerts and sound are both on, while badges are off.Using IF statements, we can do something like
To run a set block of code, or fire a particular method for when sound is disabled, but everything else is on. Anyways, hope this response is helpful to people!