From 717d09b2be403d47007f9d682f586db18987fedb Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 23 Apr 2019 07:48:22 -0500 Subject: [PATCH] Add icon badge notification number. --- iOS/AppDelegate.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index 500089111..7a5802541 100644 --- a/iOS/AppDelegate.swift +++ b/iOS/AppDelegate.swift @@ -9,6 +9,7 @@ import UIKit import RSCore import Account +import UserNotifications var appDelegate: AppDelegate! @@ -28,6 +29,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele didSet { if unreadCount != oldValue { postUnreadCountDidChangeNotification() + UIApplication.shared.applicationIconBadgeNumber = unreadCount } } } @@ -78,6 +80,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele self.unreadCount = AccountManager.shared.unreadCount } + UNUserNotificationCenter.current().requestAuthorization(options:[.badge]) { (granted, error) in + if granted { + DispatchQueue.main.async { + UIApplication.shared.registerForRemoteNotifications() + } + } + } + return true }