Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect notification center setting

My app needs to be set in iOS 5 Notification Center as 'alerts' and with 'sounds' on. From what I have found it is not possible for your app to offer setting these correctly, which would be the best option so correct me if im wrong.

So, I am looking for a procedure to detect the current settings and warn the user if these are not correct.

like image 827
Andres Canella Avatar asked Oct 15 '11 16:10

Andres Canella


1 Answers

actually it can be done with the following method -

UIRemoteNotificationType types = [UIApplicationsharedApplication].enabledRemoteNotificationTypes;

while types is

typedef enum 
{    
  UIRemoteNotificationTypeNone    = 0,   
  UIRemoteNotificationTypeBadge   = 1 << 0,   
  UIRemoteNotificationTypeSound   = 1 << 1,   
  UIRemoteNotificationTypeAlert   = 1 << 2,   
  UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3 
}

according to: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html So if you want to know if the user approved your app for notifications, all you need to do is to check whether types >= 4 be aware: this will not tell you if the user has enabled or disabled notification center for your app, it will only tell you the TYPE of the notification that the user approved

like image 192
Nir Hartmann Avatar answered Sep 28 '22 10:09

Nir Hartmann