             
             var titleText = "Turn on push Notifications"
             
-            if UIApplication.sharedApplication().isRegisteredForRemoteNotifications() {
+            if self.hasPushEnabled() {
                 titleText = "Turn off push Notifications"
             }
             


class NotificationCell: UITableViewCell {
    
    @IBOutlet weak var notificationSwitch: UISwitch!
    @IBOutlet weak var title: UILabel!
    @IBOutlet weak var subtitle: UILabel!
    
}


        let logInViewController = storyBoard.instantiateViewControllerWithIdentifier("LogInViewController") as! LogInViewController
        self.presentViewController(logInViewController, animated: true, completion: nil)
    }
    
    // MARK: - Push Notification handler
    func hasPushEnabled() -> Bool {
        //ios 8+
        if UIApplication.sharedApplication().respondsToSelector(#selector(UIApplication.currentUserNotificationSettings)) == true {
            let settings = UIApplication.sharedApplication().currentUserNotificationSettings()
            if (settings?.types.contains(.Alert) == true){
                return true
            }
            else {
                return false
            }
        } else {
            return UIApplication.sharedApplication().isRegisteredForRemoteNotifications()
        }
    }
}

extension SettingsViewController {
