{"action":"created","issue":{"url":"https://api.github.com/repos/processone/xmpp-messenger-ios/issues/26","labels_url":"https://api.github.com/repos/processone/xmpp-messenger-ios/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/processone/xmpp-messenger-ios/issues/26/comments","events_url":"https://api.github.com/repos/processone/xmpp-messenger-ios/issues/26/events","html_url":"https://github.com/processone/xmpp-messenger-ios/issues/26","id":121849793,"number":26,"title":"Value of type 'OneChat' has no member 'xmppLastActivity'","user":{"login":"draudeguti","id":1938226,"avatar_url":"https://avatars.githubusercontent.com/u/1938226?v=3","gravatar_id":"","url":"https://api.github.com/users/draudeguti","html_url":"https://github.com/draudeguti","followers_url":"https://api.github.com/users/draudeguti/followers","following_url":"https://api.github.com/users/draudeguti/following{/other_user}","gists_url":"https://api.github.com/users/draudeguti/gists{/gist_id}","starred_url":"https://api.github.com/users/draudeguti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/draudeguti/subscriptions","organizations_url":"https://api.github.com/users/draudeguti/orgs","repos_url":"https://api.github.com/users/draudeguti/repos","events_url":"https://api.github.com/users/draudeguti/events{/privacy}","received_events_url":"https://api.github.com/users/draudeguti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-12-12T11:40:40Z","updated_at":"2015-12-14T11:24:03Z","closed_at":null,"body":"Hi, when I run the example, I get in viewWillAppear from ChatViewController at __OneLastActivity.sendLastActivityQueryToJID__((recipient.jidStr), sender: **OneChat.sharedInstance.xmppLastActivity**) { :\r\n\r\n**Value of type 'OneChat' has no member 'xmppLastActivity'**"},"comment":{"url":"https://api.github.com/repos/processone/xmpp-messenger-ios/issues/comments/164414045","html_url":"https://github.com/processone/xmpp-messenger-ios/issues/26#issuecomment-164414045","issue_url":"https://api.github.com/repos/processone/xmpp-messenger-ios/issues/26","id":164414045,"user":{"login":"bisoo","id":15645784,"avatar_url":"https://avatars.githubusercontent.com/u/15645784?v=3","gravatar_id":"","url":"https://api.github.com/users/bisoo","html_url":"https://github.com/bisoo","followers_url":"https://api.github.com/users/bisoo/followers","following_url":"https://api.github.com/users/bisoo/following{/other_user}","gists_url":"https://api.github.com/users/bisoo/gists{/gist_id}","starred_url":"https://api.github.com/users/bisoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bisoo/subscriptions","organizations_url":"https://api.github.com/users/bisoo/orgs","repos_url":"https://api.github.com/users/bisoo/repos","events_url":"https://api.github.com/users/bisoo/events{/privacy}","received_events_url":"https://api.github.com/users/bisoo/received_events","type":"User","site_admin":false},"created_at":"2015-12-14T11:24:03Z","updated_at":"2015-12-14T11:24:03Z","body":"//\r\n//  OneLastActivity.swift\r\n//  XMPP-Messenger-iOS\r\n//\r\n<img width=\"960\" alt=\"2015-12-14 8 20 12\" src=\"https://cloud.githubusercontent.com/assets/15645784/11779706/4a4d82d4-a2a0-11e5-9ee8-3a6fd70b1616.png\">\r\n<img width=\"960\" alt=\"2015-12-14 8 21 26\" src=\"https://cloud.githubusercontent.com/assets/15645784/11779705/4a49eb42-a2a0-11e5-8cb6-7dd04c3d909f.png\">\r\n\r\n\r\n//  Created by Sean Batson on 2015-09-18.\r\n//  Edited by Paul LEMAIRE on 2015-10-09.\r\n//  Copyright © 2015 ProcessOne. All rights reserved.\r\n//\r\n\r\nimport Foundation\r\nimport XMPPFramework\r\n\r\npublic typealias OneMakeLastCallCompletionHandler = (response: XMPPIQ?, forJID:XMPPJID?, error: DDXMLElement?) -> Void\r\n\r\npublic class OneLastActivity: NSObject {\r\n    \r\n    var didMakeLastCallCompletionBlock: OneMakeLastCallCompletionHandler?\r\n    \r\n    // MARK: Singleton\r\n    \r\n    public class var sharedInstance : OneLastActivity {\r\n        struct OneLastActivitySingleton {\r\n            static let instance = OneLastActivity()\r\n        }\r\n        return OneLastActivitySingleton.instance\r\n    }\r\n    \r\n    // MARK: Public Functions\r\n    \r\n    public func getStringFormattedDateFrom(second: UInt) -> NSString {\r\n        if second > 0 {\r\n            let time = NSNumber(unsignedLong: second)\r\n            let interval = time.doubleValue\r\n            let elapsedTime = NSDate(timeIntervalSince1970: interval)\r\n            let dateFormatter = NSDateFormatter()\r\n            dateFormatter.dateFormat = \"HH:mm:ss\"\r\n            \r\n            return dateFormatter.stringFromDate(elapsedTime)\r\n        } else {\r\n            return \"\"\r\n        }\r\n    }\r\n    \r\n    public func getStringFormattedElapsedTimeFrom(date: NSDate!) -> String {\r\n        var elapsedTime = \"nc\"\r\n        let startDate = NSDate()\r\n        let components = NSCalendar.currentCalendar().components(NSCalendarUnit.Day, fromDate: date, toDate: startDate, options: NSCalendarOptions.MatchStrictly)\r\n        \r\n        if nil == date {\r\n            return elapsedTime\r\n        }\r\n        \r\n        if 52 < components.weekOfYear {\r\n            elapsedTime = \"more than a year\"\r\n        } else if 1 <= components.weekOfYear {\r\n            if 1 < components.weekOfYear {\r\n                elapsedTime = \"\\(components.weekOfYear) weeks\"\r\n            } else {\r\n                elapsedTime = \"\\(components.weekOfYear) week\"\r\n            }\r\n        } else if 1 <= components.day {\r\n            if 1 < components.day {\r\n                elapsedTime = \"\\(components.day) days\"\r\n            } else {\r\n                elapsedTime = \"\\(components.day) day\"\r\n            }\r\n        } else if 1 <= components.hour {\r\n            if 1 < components.hour {\r\n                elapsedTime = \"\\(components.hour) hours\"\r\n            } else {\r\n                elapsedTime = \"\\(components.hour) hour\"\r\n            }\r\n        } else if 1 <= components.minute {\r\n            if 1 < components.minute {\r\n                elapsedTime = \"\\(components.minute) minutes\"\r\n            } else {\r\n                elapsedTime = \"\\(components.minute) minute\"\r\n            }\r\n        } else if 1 <= components.second {\r\n            if 1 < components.second {\r\n                elapsedTime = \"\\(components.second) seconds\"\r\n            } else {\r\n                elapsedTime = \"\\(components.second) second\"\r\n            }\r\n        } else {\r\n            elapsedTime = \"now\"\r\n        }\r\n        \r\n        return elapsedTime\r\n    }\r\n    \r\n    // Mark: Simple last activity converter\r\n    public func getLastActivityFrom(timeInSeconds: UInt) -> String {\r\n        let time: NSNumber = NSNumber(unsignedLong: timeInSeconds)\r\n        var lastSeenInfo = \"\"\r\n        \r\n        switch timeInSeconds {\r\n        case 0:\r\n            lastSeenInfo = \"online\"\r\n        case _ where timeInSeconds > 0 && timeInSeconds < 60:\r\n            lastSeenInfo = \"last seen \\(timeInSeconds) seconds ago\"\r\n        case _ where timeInSeconds > 59 && timeInSeconds < 3600:\r\n            lastSeenInfo = \"last seen \\(timeInSeconds / 60) minutes ago\"\r\n        case _ where timeInSeconds > 3600 && timeInSeconds < 86400:\r\n            lastSeenInfo = \"last seen \\(timeInSeconds / 3600) hours ago\"\r\n        case _ where timeInSeconds > 86400:\r\n            let date = NSDate(timeIntervalSinceNow:-time.doubleValue)\r\n            let dateFormatter = NSDateFormatter()\r\n            \r\n            dateFormatter.dateFormat = \"dd.MM.yyyy\"\r\n            lastSeenInfo = \"last seen on \\(dateFormatter.stringFromDate(date))\"\r\n        default:\r\n            lastSeenInfo = \"never been online\"\r\n        }\r\n        \r\n        return lastSeenInfo\r\n    }\r\n    \r\n    // Add Last Activity Details to NavigationBar\r\n    public func addLastActivityLabelToNavigationBar(lastActivityText: String, displayName: String) -> UIView {\r\n        var userDetails: UIView?\r\n        let width = UIScreen.mainScreen().bounds.width\r\n        \r\n        userDetails = UIView(frame: CGRect(x: (width - 140) / 2, y: 25, width: 140, height: 40))\r\n        \r\n        let title = UILabel(frame: CGRect(x: 0, y: 0, width: 140, height: 17))\r\n        title.text = displayName\r\n        title.textAlignment = .Center\r\n        userDetails!.addSubview(title)\r\n        \r\n        let lastSeen = UILabel(frame: CGRect(x: 0, y: 20, width: 140, height: 12))\r\n        lastSeen.text = lastActivityText\r\n        lastSeen.font = UIFont.systemFontOfSize(10)\r\n        lastSeen.textAlignment = .Center\r\n        userDetails!.addSubview(lastSeen)\r\n        \r\n        return userDetails!\r\n    }\r\n    \r\n    public class func sendLastActivityQueryToJID(userName: String, sender: XMPPLastActivity? = nil, completionHandler completion:OneMakeLastCallCompletionHandler) {\r\n        sharedInstance.didMakeLastCallCompletionBlock = completion\r\n        let userJID = XMPPJID.jidWithString(userName)\r\n        \r\n        sender?.sendLastActivityQueryToJID(userJID)\r\n    }\r\n}\r\n\r\nextension OneLastActivity: XMPPLastActivityDelegate {\r\n    \r\n    public func xmppLastActivity(sender: XMPPLastActivity!, didNotReceiveResponse queryID: String!, dueToTimeout timeout: NSTimeInterval) {\r\n        if let callback = OneLastActivity.sharedInstance.didMakeLastCallCompletionBlock {\r\n            callback(response: nil, forJID:nil ,error: DDXMLElement(name: \"TimeOut\"))\r\n        }\r\n    }\r\n    \r\n    public func xmppLastActivity(sender: XMPPLastActivity!, didReceiveResponse response: XMPPIQ!) {\r\n        if let callback = OneLastActivity.sharedInstance.didMakeLastCallCompletionBlock {\r\n            if let resp = response {\r\n                if resp.elementForName(\"error\") != nil {\r\n                    if let from = resp.valueForKey(\"from\") {\r\n                        callback(response: resp, forJID: XMPPJID.jidWithString(\"\\(from)\"), error: resp.elementForName(\"error\"))\r\n                    } else {\r\n                        callback(response: resp, forJID: nil, error: resp.elementForName(\"error\"))\r\n                    }\r\n                } else {\r\n                    if let from = resp.attributeForName(\"from\") {\r\n                        callback(response: resp, forJID: XMPPJID.jidWithString(\"\\(from)\"), error: nil)\r\n                    } else {\r\n                        callback(response: resp, forJID: nil, error: nil)\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n    \r\n    public func numberOfIdleTimeSecondsForXMPPLastActivity(sender: XMPPLastActivity!, queryIQ iq: XMPPIQ!, currentIdleTimeSeconds idleSeconds: UInt) -> UInt {\r\n        return 30\r\n    }\r\n}"}}