| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -96,17 +96,18 @@ extension UserNotificationPresenterAdaptee: NotificationPresenterAdaptee {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        let content = UNMutableNotificationContent()
 | 
					 | 
					 | 
					 | 
					        let content = UNMutableNotificationContent()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        content.categoryIdentifier = category.identifier
 | 
					 | 
					 | 
					 | 
					        content.categoryIdentifier = category.identifier
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        content.userInfo = userInfo
 | 
					 | 
					 | 
					 | 
					        content.userInfo = userInfo
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        let isReplacingNotification = replacingIdentifier != nil
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        var isBackgroudPoll = false
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if let threadIdentifier = userInfo[AppNotificationUserInfoKey.threadId] as? String {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            content.threadIdentifier = threadIdentifier
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            isBackgroudPoll = replacingIdentifier == threadIdentifier
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        let isAppActive = UIApplication.shared.applicationState == .active
 | 
					 | 
					 | 
					 | 
					        let isAppActive = UIApplication.shared.applicationState == .active
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if let sound = sound, sound != OWSSound.none {
 | 
					 | 
					 | 
					 | 
					        if let sound = sound, sound != OWSSound.none {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            content.sound = sound.notificationSound(isQuiet: isAppActive)
 | 
					 | 
					 | 
					 | 
					            content.sound = sound.notificationSound(isQuiet: isAppActive)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					        
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        var notificationIdentifier: String = UUID().uuidString
 | 
					 | 
					 | 
					 | 
					        let notificationIdentifier = isReplacingNotification ? replacingIdentifier! : UUID().uuidString
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if let replacingIdentifier = replacingIdentifier {
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            notificationIdentifier = replacingIdentifier
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            Logger.debug("replacing notification with identifier: \(notificationIdentifier)")
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            cancelNotification(identifier: notificationIdentifier)
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if shouldPresentNotification(category: category, userInfo: userInfo) {
 | 
					 | 
					 | 
					 | 
					        if shouldPresentNotification(category: category, userInfo: userInfo) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if let displayableTitle = title?.filterForDisplay {
 | 
					 | 
					 | 
					 | 
					            if let displayableTitle = title?.filterForDisplay {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -119,10 +120,26 @@ extension UserNotificationPresenterAdaptee: NotificationPresenterAdaptee {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // Play sound and vibrate, but without a `body` no banner will show.
 | 
					 | 
					 | 
					 | 
					            // Play sound and vibrate, but without a `body` no banner will show.
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            Logger.debug("supressing notification body")
 | 
					 | 
					 | 
					 | 
					            Logger.debug("supressing notification body")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        let trigger: UNNotificationTrigger?
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if isBackgroudPoll {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            trigger = UNTimeIntervalNotificationTrigger(timeInterval: kNotificationDelayForBackgroumdPoll, repeats: false)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            let numberOfNotifications: Int
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if let lastRequest = notifications[notificationIdentifier], let counter = lastRequest.content.userInfo[AppNotificationUserInfoKey.threadNotificationCounter] as? Int  {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                numberOfNotifications = counter + 1
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                numberOfNotifications = 1
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            content.userInfo[AppNotificationUserInfoKey.threadNotificationCounter] = numberOfNotifications
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            content.body = "\(numberOfNotifications) new messages."
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } else {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            trigger = nil
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        let request = UNNotificationRequest(identifier: notificationIdentifier, content: content, trigger: nil)
 | 
					 | 
					 | 
					 | 
					        let request = UNNotificationRequest(identifier: notificationIdentifier, content: content, trigger: trigger)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Logger.debug("presenting notification with identifier: \(notificationIdentifier)")
 | 
					 | 
					 | 
					 | 
					        Logger.debug("presenting notification with identifier: \(notificationIdentifier)")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if isReplacingNotification { cancelNotification(identifier: notificationIdentifier) }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        notificationCenter.add(request)
 | 
					 | 
					 | 
					 | 
					        notificationCenter.add(request)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        notifications[notificationIdentifier] = request
 | 
					 | 
					 | 
					 | 
					        notifications[notificationIdentifier] = request
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |