Revision d206cafe

View differences:

ChatSecure/Classes/Categories/UIApplication+ChatSecure.swift
72 72
    }
73 73
    
74 74
    @objc public func showLocalNotificationForKnockFrom(_ thread:OTRThreadOwner?) {
75
        var name = SOMEONE_STRING()
76
        if let threadName = thread?.threadName {
77
            name = threadName
75
        DispatchQueue.main.async {
76
            var name = SOMEONE_STRING()
77
            if let threadName = thread?.threadName {
78
                name = threadName
79
            }
80
            
81
            let chatString = WANTS_TO_CHAT_STRING()
82
            let text = "\(name) \(chatString)"
83
            let unreadCount = self.applicationIconBadgeNumber + 1
84
            self.showLocalNotificationFor(thread, text: text, unreadCount: unreadCount)
78 85
        }
79
        
80
        let chatString = WANTS_TO_CHAT_STRING()
81
        let text = "\(name) \(chatString)"
82
        let unreadCount = self.applicationIconBadgeNumber + 1
83
        self.showLocalNotificationFor(thread, text: text, unreadCount: unreadCount)
84 86
    }
85 87
    
86 88
    @objc public func showLocalNotificationForSubscriptionRequestFrom(_ jid:String?) {
87
        var name = SOMEONE_STRING()
88
        if let jidName = jid {
89
            name = jidName
89
        DispatchQueue.main.async {
90
            var name = SOMEONE_STRING()
91
            if let jidName = jid {
92
                name = jidName
93
            }
94
            
95
            let chatString = WANTS_TO_CHAT_STRING()
96
            let text = "\(name) \(chatString)"
97
            let unreadCount = self.applicationIconBadgeNumber + 1
98
            self.showLocalNotificationWith(identifier: nil, body: text, badge: unreadCount, userInfo: [kOTRNotificationType:kOTRNotificationTypeSubscriptionRequest], recurring: false)
90 99
        }
91
        
92
        let chatString = WANTS_TO_CHAT_STRING()
93
        let text = "\(name) \(chatString)"
94
        let unreadCount = self.applicationIconBadgeNumber + 1
95
        self.showLocalNotificationWith(identifier: nil, body: text, badge: unreadCount, userInfo: [kOTRNotificationType:kOTRNotificationTypeSubscriptionRequest], recurring: false)
96 100
    }
97 101
    
98 102
    @objc public func showLocalNotificationForApprovedBuddy(_ thread:OTRThreadOwner?) {
99
        var name = SOMEONE_STRING()
100
        if let buddyName = (thread as? OTRBuddy)?.displayName {
101
            name = buddyName
102
        } else if let threadName = thread?.threadName {
103
            name = threadName
103
        DispatchQueue.main.async {
104
            var name = SOMEONE_STRING()
105
            if let buddyName = (thread as? OTRBuddy)?.displayName {
106
                name = buddyName
107
            } else if let threadName = thread?.threadName {
108
                name = threadName
109
            }
110
            
111
            let message = String(format: BUDDY_APPROVED_STRING(), name)
112
            
113
            let unreadCount = self.applicationIconBadgeNumber + 1
114
            self.showLocalNotificationFor(thread, text: message, unreadCount: unreadCount)
104 115
        }
105
        
106
        let message = String(format: BUDDY_APPROVED_STRING(), name)
107
        
108
        let unreadCount = self.applicationIconBadgeNumber + 1
109
        self.showLocalNotificationFor(thread, text: message, unreadCount: unreadCount)
110 116
    }
111 117
    
112 118
    internal func showLocalNotificationFor(_ thread:OTRThreadOwner?, text:String, unreadCount:Int) {

Also available in: Unified diff