在QuickBlox中创建聊天室

时间:2013-01-03 13:45:29

标签: iphone ios xmppframework quickblox

我正在尝试使用我的iOS应用在QuickBlox创建一个聊天室。

[[QBChat instance] createPrivateRoomWithName:@"My Room"];


- (void)createPrivateRoomWithName:(QBChatRoom*)room{
    NSLog(@"Private room %@ was created", room.name);

    // Add users to this room
    NSNumber *anny = [NSNumber numberWithInt:300];
    NSNumber *jim = [NSNumber numberWithInt:357];
    NSArray *users = [NSArray arrayWithObjects:anny, jim, nil];

    [[QBChat instance] addUsers:users toRoom:room];
}

但在使用此代码后,我的应用程序崩溃,下面是崩溃日志。

2013-01-03 19:13:55.234 Chat.Points[11178:23d03] +[QBDDXMLElement elementWithName:xmlns:]: unrecognized selector sent to class 0x22f73c
2013-01-03 19:13:55.241 Chat.Points[11178:23d03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[QBDDXMLElement elementWithName:xmlns:]: unrecognized selector sent to class 0x22f73c'
*** First throw call stack:
(0x32fe012 0x29eae7e 0x33892ad 0x32edbbc 0x32ed94e 0x101e05 0x2da153f 0x2db3014 0x2da3418 0x2da32a6 0x2da4280 0x2da3fcb 0x990f7b24 0x990f96fe)
libc++abi.dylib: terminate called throwing an exception

enter image description here

2 个答案:

答案 0 :(得分:2)

您必须在创建空间之前登录QuickBlox Chat。

解决方案是:

1)你必须将 -ObjC 标志添加到其他链接器标志

2)添加到SplashController.h聊天委托QBChatDelegate

@interface SplashController : UIViewController <QBActionStatusDelegate, FBServiceResultDelegate, FBSessionDelegate, QBChatDelegate>{

3)添加到SplashController.m,

如果

}else if([result isKindOfClass:[QBMRegisterSubscriptionTaskResult class]]){

在顶部的下一行:

    // Login to QuickBlox Chat
    //
    [[QBChat instance] setDelegate:self];
    [DataManager shared].currentQBUser.password = [NSString stringWithFormat:@"%u", [[[DataManager shared].currentFBUser objectForKey:kId] hash]];
    [[QBChat instance] loginWithUser:[DataManager shared].currentQBUser];
    //
    //

4)最后,添加到最后

#pragma mark-
#pragma mark QBChatDelegate

- (void)chatDidLogin{
    [[QBChat instance] createPrivateRoomWithName:@"ChatRRoom"];
}

- (void)chatRoomDidCreate:(QBChatRoom *)room{
    NSLog(@"Room did create %@", room);
    myRoom = [room retain];
}

答案 1 :(得分:0)

在目标设置中的其他链接器标志中添加-ObjC标志。希望它能解决你的问题。