我大约6个月后从这个链接下载了robbiehanson/XMPPFramework:https://github.com/robbiehanson/XMPPFramework。我遵循Getting Started部分中提到的步骤。它没有抛出任何错误。试着按照这些步骤来设置你的应用程序的xmppframework。
在示例应用程序中,我找到了我在启动应用程序时调用的函数setupStream()
。在这个函数中,我创建一个xmppStream并激活我的应用程序中需要的不同模块。例如
xmppStream = [[XMPPStream alloc] init];
// Activate xmpp modules after creating them
[xmppReconnect activate:xmppStream];
[xmppRoster activate:xmppStream];
[xmppvCardTempModule activate:xmppStream];
[xmppvCardAvatarModule activate:xmppStream];
[xmppCapabilities activate:xmppStream];
// Add ourself as a delegate to anything we may be interested in
[xmppStream addDelegate:self delegateQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
[xmppStream setHostName:XMPPHOST];
[xmppStream setHostPort:5222];
// You may need to alter these settings depending on the server you're connecting to
allowSelfSignedCertificates = NO;
allowSSLHostNameMismatch = NO;
设置流之后,你需要做这样的鉴定:
- (BOOL)connect:(NSString *)myJID //username registered with server
{
if (![xmppStream isDisconnected]) {
return YES;
}
if (myJID == nil) {
return NO;
}
[xmppStream setMyJID:[XMPPJID jidWithString:myJID]];
NSError *error = nil;
if (![xmppStream connect:&error])
{
if(DEBUG)
{
NSLog(@"ERROR: Not connected to XMPP Server");
}
DDLogError(@"Error connecting: %@", error);
return NO;
}
return YES;
}
此功能将被框架调用,通过这里的密码:
- (void)xmppStreamDidConnect:(XMPPStream *)sender
{
if(sender == xmppStream)
{
//DDLogVerbose(@"In xmppStream: %@: %@", THIS_FILE, THIS_METHOD);
isXmppConnected = YES;
NSError *error = nil;
if (![[self xmppStream] authenticateWithPassword:password error:&error])
{
DDLogError(@"Error authenticating: %@", error);
}
}
}
现在如果用户通过认证,此功能将被称为:
- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender
{
if(sender == xmppStream)
{
[self goOnline];
}
}
goOnline将发送用户的存在服务器:
- (void)goOnline
{
XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit
[xmppStream sendElement:presence];
}
现在,您可以发送/接收消息/存在等
2几年前,我下载了它的基本版本。不是更新的,并且完成了一个POC推送通知。在那里我配置了gtalk,后来poc被纳入雷达。现在我没有任何源代码可以帮助你,但我想帮助你... – 2013-02-28 09:28:38
好的..谢谢你@AnoopVaidya – Babul 2013-02-28 09:29:51
@BabulI已经将XMPP框架及其所有依赖项添加到我的iPhone聊天应用程序中,并且它没有给出任何错误(已成功构建)。现在你可以帮我,现在我需要在我的应用程序中添加XMPP框架后做些什么..?谢谢 – 2014-01-23 07:55:41