creating chat room in QuickBlox

瘦欲@ 提交于 2019-12-23 04:24:37

问题


I am trying to create a chat room in QuickBlox using my iOS app.

[[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];
}

but after using this code my application is crashing, below is the crash log.

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


回答1:


You have to login to QuickBlox Chat before creating room.

The solution is:

1) you have to add -ObjC flag to Other Linker Flags

2) Add to SplashController.h chat delegate QBChatDelegate

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

3) Add to SplashController.m,

to if

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

at the top next lines:

    // 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) Finally, add to the end

#pragma mark-
#pragma mark QBChatDelegate

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

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



回答2:


Just Add -ObjC flag in Other Linker Flags in your targets' settings. Hope it will solve your problem.



来源:https://stackoverflow.com/questions/14140132/creating-chat-room-in-quickblox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!