Friday, August 28, 2015

how to fix an error of notification " time zone = (null), repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = user info = (null)} with an alert but haven't received permission from the user to display alerts by swift

When I tried to make a notification, I encountered this error showing on debug area.

(shows your timezone)  time zone = (null), repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = (shows your fire date)  user info = (null)} with an alert but haven't received permission from the user to display alerts

It means iOS8 needs user's permission.

How to solve;

add code in func application( application : ---- ) on AppDelegate.swift like following.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound |
            UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories:nil))
        
        return true

    }

FYI
http://stackoverflow.com/questions/24100313/ask-for-user-permission-to-receive-uilocalnotifications-in-ios-8

No comments:

Post a Comment