xmpp-messenger-ios 1.0.1

xmpp-messenger-ios 1.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2015
SPMSupports SPM

Maintained by ProcessOne.


Downloads

Total10,132
Week0
Month0

Installs

Apps1,834
Pod Tries18
Test Targets86
powered by Segment

GitHub

Stars167
Watchers29
Forks73
Issues16
Contributors6
Pull Requests1

Code

Files7
LOCLines of Code 596


 
Depends on:
FMDB~> 1.0
JSQMessagesViewController>= 0
JSQSystemSoundPlayer~> 2.0
XMPPFramework>= 0
 

  • By
  • ProcessOne

xmpp-messenger-ios

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

xmpp-messenger-ios is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "xmpp-messenger-ios"

Author

ProcessOne, [email protected]

License

xmpp-messenger-ios is available under the MIT license. See the LICENSE file for more info.

OneChat

Swift XMPP client using P1 Swift XMPP framework

Usage

Download or clone the project

AppDelegate

Add this in your AppDelegate’s did finishLaunchingWithOptions to start the stream :

OneChat.start(archiving: true, delegate: nil) { (stream, error) -> Void in

}

Add in applicationWillTerminate to stop the stream :

OneChat.stop()

BuddyList

To get the buddy list, just conform to OneRosterDelegate by implementing the delegate :

func oneRosterContentChanged(controller: NSFetchedResultsController) {
  tableView.reloadData() //Reload or other
}

Messaging

Receive a message

To be able to send messages, you must conform to OneMessageDelegate :

First set yourself as listener in viewdidload

override func viewDidLoad() {
super.viewDidLoad()

OneMessage.sharedInstance.delegate = self
}

then implement the protocol :

func oneStream(sender: XMPPStream, didReceiveMessage message: XMPPMessage, from user: XMPPUserCoreDataStorageObject) {

if message.isChatMessageWithBody() {
let body = message.elementForName("body").stringValue()
let displayName = user.displayName

if let msg: String = message.elementForName("body")?.stringValue() {
if let from: String = message.attributeForName("from")?.stringValue() {
messagestTableView.reloadData() //Reload or other
}
}
}
}

Send a message :

OneMessage.sendMessage(youMessage, to: chatJid, completionHandler: { (stream, message) -> Void in

})