Question

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

enter image description here

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top