Giter Club home page Giter Club logo

qmchatviewcontroller-ios's Introduction

QMChatViewController is deprecated and won't be supported.

CocoaPods CocoaPods CocoaPods

An elegant ready-to-go chat view controller for iOS chat applications that use Quickblox communication backend.

#Features

  • Ready-to-go chat view controller with a set of cells.
  • Automatic cell size calculation.
  • UI customization for chat cells.
  • Flexibility in improving and extending functionality.
  • Easy to connect with Quickblox.
  • Optimized and performant.
  • Supports portrait and landscape orientations.
  • Auto Layout inside.

Screenshots

Chat View Controller

Requirements

  • iOS 8.0+
  • ARC
  • Xcode 6+
  • Quickblox SDK 2.0+
  • TTTAttributedLabel
  • SDWebImage

Installation

CocoaPods

pod 'QMChatViewController'

Manually

  • Drag QMChatViewController folder to your project folder and link to the appropriate target.

  • Install dependencies.

Dependencies

Getting started

An example is included in the repository. Try it out to see how chat view controller works.

Steps to add QMChatViewController to Your app:

  1. Create a subclass of QMChatViewController. You could create it both from code and Interface Builder.

  2. Open your subclass of QMChatViewController and do the following in viewDidLoad method:

    • Configure chat sender ID and display name:
    self.senderID = 2000;
    self.senderDisplayName = @"user1";
    • Insert messages using corresponding methods:
    [self.chatDataSource addMessages:<array of messages>];
  3. Handle message sending.

    - (void)didPressSendButton:(UIButton *)button
    	       withMessageText:(NSString *)text
    			      senderId:(NSUInteger)senderId
     		 senderDisplayName:(NSString *)senderDisplayName
                  		  date:(NSDate *)date {
    	// Add sending message - for example:
        QBChatMessage *message = [QBChatMessage message];
    	message.text = text;
    	message.senderID = senderId;
    
    	QBChatAttachment *attacment = [[QBChatAttachment alloc] init];
    	message.attachments = @[attacment];
    
    	[self.chatDataSource addMessage:message];
    
    	[self finishSendingMessageAnimated:YES];
    
     	// Save message to your cache/memory storage.                     
    	// Send message using Quickblox SDK
    }
  4. Return cell view classes specific to chat message:

    - (Class)viewClassForItem:(QBChatMessage *)item {
        // Cell class for message
        if (item.senderID != self.senderID) {
            
            return [QMChatIncomingCell class];
        }
        else {
            
            return [QMChatOutgoingCell class];
        }
    
        return nil;
    }
    
  5. Calculate size of cell and minimum width:

    - (CGFloat)collectionView:(QMChatCollectionView *)collectionView minWidthAtIndexPath:(NSIndexPath *)indexPath {
    
        QBChatMessage *item = [self.chatDataSource messageForIndexPath:indexPath];
        
        NSAttributedString *attributedString = item.senderID == self.senderID ?
        [self bottomLabelAttributedStringForItem:item] : [self topLabelAttributedStringForItem:item];
        
        CGSize size = [TTTAttributedLabel sizeThatFitsAttributedString:attributedString
                                                       withConstraints:CGSizeMake(1000, 10000)
                                                limitedToNumberOfLines:1];
        return size.width;
    }
  6. Top, bottom and text labels.

    - (NSAttributedString *)attributedStringForItem:(QBChatMessage *)messageItem {
        
        UIColor *textColor = [messageItem senderID] == self.senderID ?
        [UIColor whiteColor] : [UIColor colorWithWhite:0.290 alpha:1.000];
        
        UIFont *font = [UIFont fontWithName:@"Helvetica" size:15];
        NSDictionary *attributes = @{NSForegroundColorAttributeName:textColor,
                                     NSFontAttributeName:font};
        
        NSMutableAttributedString *attrStr =
        [[NSMutableAttributedString alloc] initWithString:messageItem.text
                                               attributes:attributes];
        return attrStr;
    }
    
    - (NSAttributedString *)topLabelAttributedStringForItem:(QBChatMessage *)messageItem {
        
        if (messageItem.senderID == self.senderID) {
            
            return nil;
        }
        
        UIFont *font = [UIFont fontWithName:@"Helvetica" size:14];
        
        UIColor *textColor = [UIColor colorWithRed:0.184 green:0.467 blue:0.733 alpha:1.000];
        
        NSDictionary *attributes = @{NSForegroundColorAttributeName:textColor,
                                     NSFontAttributeName:font};
        
        NSMutableAttributedString *attrStr =
        [[NSMutableAttributedString alloc] initWithString:@"nickname"
                                               attributes:attributes];
        return attrStr;
    }
    
    - (NSAttributedString *)bottomLabelAttributedStringForItem:(QBChatMessage *)messageItem {
        
        UIFont *font = [UIFont fontWithName:@"Helvetica" size:12];
        UIColor *textColor = [messageItem senderID] == self.senderID ?
        
        [UIColor colorWithWhite:1.000 alpha:0.510] : [UIColor colorWithWhite:0.000 alpha:0.490];
        
        NSDictionary *attributes = @{NSForegroundColorAttributeName:textColor,
                                     NSFontAttributeName:font};
        
        NSString *dateStr = @"10:20";
        
        NSMutableAttributedString *attrStr =
        [[NSMutableAttributedString alloc] initWithString:dateStr
                                               attributes:attributes];
        return attrStr;
    }
  7. Modifying collection chat cell attributes without changing constraints:

    struct QMChatLayoutModel {
    
    	CGSize avatarSize;
    	CGSize containerSize;
    	UIEdgeInsets containerInsets;
    	CGFloat topLabelHeight;
    	CGFloat bottomLabelHeight;
    	CGSize staticContainerSize;
    	CGFloat maxWidthMarginSpace;
    };
    
    typedef struct QMChatLayoutModel QMChatCellLayoutModel;
    • size of the avatar image view
    • message view container size
    • top label height
    • bottom label height
    • static size of container view
    • margin space between message and screen end

    You can modify this attributes in this method:

    - (QMChatCellLayoutModel)collectionView:(QMChatCollectionView *)collectionView layoutModelAtIndexPath:(NSIndexPath *)indexPath {
    
    	QMChatCellLayoutModel layoutModel = [super collectionView:collectionView layoutModelAtIndexPath:indexPath];
    	//Update attributes here ...
    	return layoutModel;
    }

    So if you want to hide top label or bottom label you just need to set their height to 0.

Attachments

QMChatViewController supports image attachment cell messages. QMChatAttachmentIncomingCell is used for incoming attachments, QMChatAttachmentOutgoingCell is used for outgoing attachments. Both of them have progress label to display loading progress. XIB's are also included.

Chat data source

QMChatViewController contains its data source manager called QMChatDataSource. It has implementation of all methods, which you need to work with QMChatViewController. This class should be used to add, update and delete messages from data source. QMChatDataSource has delegate, which called whenever data source were modified.

For more information on methods and its usage check out our inline doc in QMChatDataSource.h.

Questions & Help

  • You could create an issue on GitHub if you are experiencing any problems. We will be happy to help you.
  • Or you can ask a 'quickblox' tagged question on StackOverflow http://stackoverflow.com/questions/ask

Documentation

Inline code documentation available.

License

See LICENSE

qmchatviewcontroller-ios's People

Contributors

forsarion avatar glebus avatar isevendays avatar pro100andrey avatar sshaforenkoqb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qmchatviewcontroller-ios's Issues

Crashing when rotating while messages are being added

Things seem to be crashing while rotating (feels like some kind of a race condition)

2016-04-08 15:51:21.270 imhr-ios[40586:15177614] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000102550d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000100d7fdeb objc_exception_throw + 48
    2   CoreFoundation                      0x00000001024f8885 -[__NSArray0 objectAtIndex:] + 101
    3   imhr-ios                            0x0000000100014e69 -[QMChatSectionManager messageForIndexPath:] + 126
    4   imhr-ios                            0x0000000100018956 -[QMChatViewController collectionView:itemIdAtIndexPath:] + 77
    5   imhr-ios                            0x0000000100010680 -[QMChatCollectionViewFlowLayout containerViewSizeForItemAtIndexPath:] + 143
    6   imhr-ios                            0x0000000100010ad7 -[QMChatCollectionViewFlowLayout sizeForItemAtIndexPath:] + 31
    7   imhr-ios                            0x00000001000188e1 -[QMChatViewController collectionView:layout:sizeForItemAtIndexPath:] + 50
    8   UIKit                               0x00000001052334f7 -[UICollectionViewFlowLayout _getSizingInfos] + 1891
    9   UIKit                               0x0000000105234c47 -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 118
    10  UIKit                               0x000000010522e3fd -[UICollectionViewFlowLayout prepareLayout] + 273
    11  UIKit                               0x000000010524ec3d -[UICollectionViewData _prepareToLoadData] + 67
    12  UIKit                               0x000000010524f411 -[UICollectionViewData validateLayoutInRect:] + 53
    13  UIKit                               0x0000000105252368 -[UICollectionViewData layoutAttributesForElementsInRect:] + 161
    14  UIKit                               0x00000001051f6c2d -[UICollectionView _updateVisibleCellsNow:] + 531

    16  UIKit                               0x0000000105206eab -[UICollectionView _updateSections:updateAction:] + 119
    17  UIKit                               0x000000011a18c00b -[UICollectionViewAccessibility deleteSections:] + 43
    18  imhr-ios                            0x0000000100016add __111-[QMChatViewController chatSectionManager:didDeleteMessagesWithIDs:atIndexPaths:withSectionsIndexSet:animated:]_block_invoke + 117
    19  imhr-ios                            0x0000000100016953 -[QMChatViewController chatSectionManager:didDeleteMessagesWithIDs:atIndexPaths:withSectionsIndexSet:animated:] + 618
    20  imhr-ios                            0x0000000100013f98 __48-[QMChatSectionManager deleteMessages:animated:]_block_invoke_2 + 258
    21  libdispatch.dylib                   0x00000001062db3d7 _dispatch_client_callout + 8
    22  libdispatch.dylib                   0x00000001062c6e2f _dispatch_barrier_sync_f_slow_invoke + 65
    23  libdispatch.dylib                   0x00000001062db3d7 _dispatch_client_callout + 8
    24  libdispatch.dylib                   0x00000001062c5e5d _dispatch_main_queue_callback_4CF + 714
    25  CoreFoundation                      0x00000001024aa0f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    26  CoreFoundation                      0x000000010246bb99 __CFRunLoopRun + 2073
    27  CoreFoundation                      0x000000010246b0f8 CFRunLoopRunSpecific + 488
    28  GraphicsServices                    0x00000001072c5ad2 GSEventRunModal + 161
    29  UIKit                               0x000000010497cf09 UIApplicationMain + 171
    30  imhr-ios                            0x000000010004a072 main + 146
    31  libdyld.dylib                       0x000000010630a92d start + 1

issue in QMChatviewcontroller example

i am unable to run QMChatviewcontroller demo. get some lib error.. No issue.I created new project ,added QMChatviewcontroller through pods. Used same code from file 'DemoChatViewController' given in QMChatviewcontroller. I have just kept 2 messgaes. Plesae see the screenshot how it is looking. Look at first message. It is coming automatically. Today header must not be included in a message. Also, why the collectionview is scrolled to bottom? I tried setting automaticallyScrollsToMostRecentMessage to NO. still there is no effect?
I installed QMChatviewcontroller using command yesterday =>
pod 'QMChatViewController'

screen shot 2016-12-10 at 12 08 13 am

Please check.

chatCellDidTapAvatar does not work

It seems like it should use QMImageView's imageViewDidTap but instead it uses

  • (void)handleTapGesture:(UITapGestureRecognizer *)tap {

    CGPoint touchPt = [tap locationInView:self];

    if (CGRectContainsPoint(self.avatarContainerView.frame, touchPt)) {
    [self.delegate chatCellDidTapAvatar:self];
    }

Pod file is not in a wroking state

Analyzing dependencies
[!] The dependency QuickBlox (= 2.5) is not used in any concrete target.
The dependency QMCVDevelopment (from../) is not used in any concrete target.

Add targets to pod file like this

target 'QMChatViewControllerExample' do
pod 'QuickBlox', '2.5'
pod 'QMCVDevelopment', :path => '../'
end

Crashes when pressing Send button.

When pressing the Send button, I get the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSConcreteMutableAttributedString initWithString:attributes:: nil value'

Both on sample project and when tried to use in my own project.

When debugging, I noticed that it crashes when processing this line:
CGFloat collectionViewContentHeight = [self.collectionView.collectionViewLayout collectionViewContentSize].height;
That's inside scrollToBottomAnimated: method.

Any help?

Still crash after send message

I'm using version 0.3.3.
I send some messages and it crash.
Here is the detail

2016-01-15 11:26:30.810 Sembang DEV[537:149053] *** Assertion failure in -[QMChatCollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.30.14/UICollectionView.m:4308
2016-01-15 11:26:35.976 Sembang DEV[537:149053] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections.  The number of sections contained in the collection view after the update (8) must be equal to the number of sections contained in the collection view before the update (4), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'

App getting crash after calling method `insertMessagesToTheBottomAnimated`

I am calling insertMessagesToTheBottomAnimated method in viewDidLoad method from subcalass of QMChatViewController and getting following error and crash

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSConcreteMutableAttributedString initWithString:attributes:: nil value'

I am using version 0.3 of QMChatViewController

[!] Error installing QMServicesDevelopment - Swift

Pods I'm trying to install for swift:

pod 'QMCVDevelopment', :git => 'https://github.com/QuickBlox/QMChatViewController-ios.git', :branch => 'development'

pod 'QMServicesDevelopment', :git => '[email protected]:QuickBlox/q-municate-services-ios.git', :branch => 'development'

Following error I'm getting:

[!] Error installing QMServicesDevelopment
[!] /usr/bin/git clone [email protected]:QuickBlox/q-municate-services-ios.git /var/folders/kg/lqh4pqdd4z1dx261hqh97j340000gp/T/d20160211-3686-1159reo --single-branch --depth 1 --branch development

Cloning into '/var/folders/kg/lqh4pqdd4z1dx261hqh97j340000gp/T/d20160211-3686-1159reo'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Crash when received offline message.

I've tried your Q-municate app in appstore and also integrate your UI in my demo app. After that, I found some crash bugs when send/received messages.
They happen when reload collection view by method performBatchUpdate without correct dataSource.
Please review and fix soon ASAP.

How do we show the typing indicator?

I saw in this doc - http://cocoadocs.org/docsets/QMChatViewController/0.2.2/Classes/QMChatViewController.html - that there is a property called showTypingIndicator but it seems to be missing in the latest build. Is there another way to show a typing indicator?

Help avoid duplicate issue reports, check existing issues

Environment details
iOS version, Quickblox iOS SDK version, QMChatViewController version

Did this work before?

Expected behavior

Actual behavior

Logs
Attach full logs that will describe your problem (please, use github gist)

Steps to reproduce the behavior

Any others comments?

QMChatViewController using as is

Hey guys, I looked trough your demo project for swift, my question is can I use QMChatViewController without writing or overriding it. So I mean that in your demo project you've added a lot of sources and for now after migration from previous version to new one it's hard to migrate for me all code. at least that we don't have any section manager before and I also has my custom object that handle for me authorization and mange quick block dialogs features.

thanks

QMChatSectionManager alternative

Hi, I need an alternative to QMChatSectionManager, since it's been deprecated in v0.4.
We use it in places like:

#pragma mark - QMChatCollectionViewDelegateFlowLayout
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    NSInteger count = [self.chatSectionManager messagesCountForSectionAtIndex:section];
    if (count > 0) [UIView animateWithDuration:0.35f animations:^{
        self.collectionView.alpha = 1.0f;
    }]; return count;
}

For [self.chatDataSource messageForIndexPath:indexPath] and some other occasions it's ok, chatDataSource works fine -- but sometimes I need messagesCountForSectionAtIndex or chatSectionAtIndex, but those aren't present in chatDataSource and don't seem to work anymore with chatSectionManager.

Environment details
QMChatViewController v0.4.0.1

Did this work before?
Yes, before v0.4

Hope you guys can help me. Thanks :)

Never call dealloc

I tried your demo and found that the view controller never call dealloc function.
You are using "self" instance in some block methods.

Suggestion - make constraints in QMCell nib files IBOutlets that can be configured.

I am not sure where to put this but figured I'd just put it here. Feel free to close if this isn't the place for this.

I was trying to get rid of the space that was around the image in the QMChatAttachmentIncoming/Outgoing cells and finally figured out that it was a constraint down in the xib file. I removed the values so now there is no border around it.

However I had to modify the actual xib file in the project instead, so if I ever update it's going to be wiped away.

Just a suggestion to make those constraints configurable so that this isn't necessary.

How to change the style of sending date of the message

I have tried with this QMChatViewController and it looks easy to use. However, in order to make it integrate into a real product, we need to customize the style of sending date of the message. Currently, the design looks not good.
I also download Q-municate in my iphone and it shows the date information elegantly. It has the day information as the header section in the chat view.
Can you help show me how to implement similar way in QMChatViewController?

How to customised or else use my own nib for tool bar in ChatViewController using Quickblox?

I want to use a custom tool bar for my chat view controller instead of existing tool bar available in sample-chat-IOS app.

And I don't want to disturb exiting QMToolbarContentView.nib and QMToolbarContentView.h and QMToolbarContentView.m files. Below Image 1 is the existing one. and Image 2 is what I want.

So which is the best to load my own tool bar nib. Is it possible or I should modify the existing one ?

And I found one method but don't know weather this will work ?

Please go through this stack over flow link to see the images and complete question.

[http://stackoverflow.com/questions/37215391/how-to-customised-or-else-use-my-own-nib-for-tool-bar-in-chatviewcontroller-usin]

Environment details
iOS version, Quickblox iOS SDK version, QMChatViewController version

Handle tap in message item

Hi,
Can you show me how to handle tap action in message with picture attachment please?
I tried collectionView:didSelectItemAtIndexPath but it never called.

Thank you.

UIMenuItem doesn't work

I added menu item to UIMenuController as below:

- (void)viewDidLoad {
    [super viewDidLoad];

    ......
    [QMChatCell registerMenuAction:@selector(resendMessage:)];
    UIMenuItem* item = [[UIMenuItem alloc] initWithTitle:@"Resend" action:@selector(resendMessage:)];
    [UIMenuController sharedMenuController].menuItems = @[item];
    ......
}

- (BOOL)collectionView:(UICollectionView*)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath*)indexPath {
    QBChatMessage* item = [self.chatSectionManager messageForIndexPath:indexPath];
    if (item.contentType == MessageContentTypeText) {
        return [super collectionView:collectionView shouldShowMenuForItemAtIndexPath:indexPath];
    }
    return NO;
}

- (BOOL)collectionView:(UICollectionView*)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender {
    QBChatMessage* item = [self.chatSectionManager messageForIndexPath:indexPath];
    if (item.contentType == MessageContentTypeText) {
        return action == @selector(copy:) || action == @selector(resendMessage:);
    }
    return NO;
}

- (void)collectionView:(UICollectionView*)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender {
    QBChatMessage* message = [self.chatSectionManager messageForIndexPath:indexPath];
    if (action == @selector(copy:)) {
        [UIPasteboard generalPasteboard].string = message.messageText ? : EMPTY_STRING;
    } else if (action == @selector(resendMessage:)) {
        [self resendMessage:indexPath];
    }
    return;
}

- (void)resendMessage:(id)sender {
    DLogWarn();
}

Menu showed up as I expected. But when I tap to Resend item, there is nothing happen.

Maybe I have not putted selector to cell.

  -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: cut:�
  -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: copy:�
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: select:�
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: selectAll:�
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: delete:�
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: _promptForReplace:
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: _showTextStyleOptions:
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: _addShortcut:
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: _accessibilitySpeakLanguageSelection:�[;
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: _accessibilityPauseSpeaking:�
 -[ChatViewController collectionView:canPerformAction:forItemAtIndexPath:withSender:] [Line 1184] 
ACTION: makeTextWritingDirectionRightToLeft:�

What should I do in this case? Thanks!

App crashing when a video is attached in quickblox chat room

//here is problem

  • (QBChatMessage *)messageForIndexPath:(NSIndexPath *)indexPath
    {
    if (indexPath.item == NSNotFound)
    {
    return nil;
    }
    QMChatSection *currentSection = self.chatSections[indexPath.section];
    return currentSection.messages[indexPath.item];
    }

/*
Exception is
*** Assertion failure in -[QMChatCollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:], /SourceCache/UIKit_Sim/UIKit-3347.44.2/UICollectionView.m:4056

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (2) must be equal to the number of sections contained in the collection view before the update (1), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'

*/

How To change Chatview collection size?

Help avoid duplicate issue reports, check existing issues

Environment details
iOS version, Quickblox iOS SDK version, QMChatViewController version
I Want To change Y position of QMChatviewcontroller.
How can i change collectionview y position.
Did this work before?

Expected behavior

Actual behavior

Logs
Attach full logs that will describe your problem (please, use github gist)

Steps to reproduce the behavior

Any others comments?

swift version

Hi,

any swift version for this sample available?

Thanks
Hiren

Instead of Time headers I am getting date based messages

Help avoid duplicate issue reports, check existing issues

Environment details
iOS version, Quickblox iOS SDK version, QMChatViewController version
ios 10, Quickblox iOS SDK 2.9

Did this work before?
No

Expected behavior
chatDataSource.addMessages should add my messages to the chatDataSource.

Actual behavior
chatDataSource.addMessages adds my messages to the chatDataSource but also adds additional cells with Time headers added as information.

Logs
Attach full logs that will describe your problem (please, use github gist)

ID: 583d04ed5b5f42373e0041d0
senderID: 19921115
recipientID: 0
dateSent: 2016-11-25 08:00:00 +0000
text: November 25
customParameters: {
kQBDateDividerCustomParameterKey = 1;
}
attachments: (null)
delayed: 0
dialogID: (null)
read: 0
readIDs: (null)
deliveredIDs: (null)
markable: 0
createdAt: (null)
updatedAt: (null)

Steps to reproduce the behavior

Any others comments?
I just want to remove these cells from my chatview. Is there an easy way to do this?

How to stop the jumbling and Flickering of images.

Hi,
While sending the continuous images in the chat , flickering and jumbling is occurring. please give suggestions. how to stop the flickering and jumbling.It is occurring in the chat sample too.
Thank you

Store Chats in SQLite DB

I want to store my previous chats in DB then show from there in ChatviewController.
In Which method i will get the all the messages with respect to dialog id.

I debug the Sample chat and found QBChatDatasource have all the chats but didn't confident.
Please tell me where i will get the all the message. So that i will store it for future if internet not available, show old messages from the chat.

Kindly help me.

sectionHeaderAtIndexPath Method replacement as it's Deprecated

Help avoid duplicate issue reports, check existing issues

Environment details
iOS version, Quickblox iOS SDK version, QMChatViewController version
I am looking for replacement for below method as it's Deprecated in new version of quickblox.
Method :

  • (UICollectionReusableView *)collectionView:(QMChatCollectionView *)collectionView
    sectionHeaderAtIndexPath:(NSIndexPath *)indexPath DEPRECATED_MSG_ATTRIBUTE("Deprecated in 0.4.0.")

I didn't find it anywhere. I would like to display "Today" and "Tomorrow" view in the chat controller.

QMImageView setting image with url bug

When setting image from url via setImageWithURL: then setting it from an image (via Camera or Library)

we will not be able to change the image via setImageWithURL: anymore.

I think that this is caused by the following test in setImageWithURL: method:

if ([url isEqual:self.url]) {
return;
}

UIMenuController - When adding custom action Crashes when cell deallocates

//iOS version- 9.3, Quickblox iOS SDK version- 2.0, QMChatViewController version- Latest

// Problem :- When I use UIMenuController to navigate to any view controller and when I navigate back to ChatView and pop to dialogue view It crashes because of ChatCell is been Deallocated .

Example : - create a forward menuController Item and just navigate to any view controller and just click on back to chat view controller and then back to recent chat view controller

// in QMChatViewController.m
`- (void)viewDidLoad {

[super viewDidLoad];

[[[self class] nib] instantiateWithOwner:self options:nil];

[self configureMessagesViewController];
[self registerForNotifications:YES];

//Customize your toolbar buttons
self.inputToolbar.contentView.leftBarButtonItem = [self accessoryButtonItem];
self.inputToolbar.contentView.rightBarButtonItem = [self sendButtonItem];
[QMChatCell registerMenuAction:@selector(forward:)];
self.collectionView.transform = CGAffineTransformMake(1, 0, 0, -1, 0, 0);

}`

`- (void)didReceiveMenuWillShowNotification:(NSNotification *)notification {

if (!self.selectedIndexPathForMenu) {
    return;
}

[[NSNotificationCenter defaultCenter] removeObserver:self
                                                name:UIMenuControllerWillShowMenuNotification
                                              object:nil];

UIMenuController *menu = [notification object];
[menu setMenuVisible:NO animated:NO];

selectedCell = (QMChatCell *)[self.collectionView cellForItemAtIndexPath:self.selectedIndexPathForMenu] ;
CGRect selectedCellMessageBubbleFrame = [selectedCell convertRect:selectedCell.containerView.frame toView:self.view];

UIMenuItem *forward = [[UIMenuItem alloc] initWithTitle:@"forward" action:@selector(forward:)];


[menu setMenuItems:[NSArray arrayWithObjects:forward,nil]];
[menu setTargetRect:selectedCellMessageBubbleFrame inView:self.view];
[menu setMenuVisible:YES animated:YES];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(didReceiveMenuWillShowNotification:)
                                             name:UIMenuControllerWillShowMenuNotification
                                           object:nil];

}`

// In chatViewController.m

`- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {

return action == @selector(copy:) || action == @selector(forward:) ;

}`

`- (void)chatCell:(QMChatCell *)cell didPerformAction:(SEL)action withSender:(id)sender {

NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell];

QBChatMessage *message = [self.chatSectionManager messageForIndexPath:indexPath];

if ([NSStringFromSelector(action) isEqualToString:@"forward:"]) {
    //NSLog(@"hhhhhh");
    [self performSegueWithIdentifier:@"forwardMessage"  sender:nil];
}

}
`

It works perfectly I can get the action and can able to perform segue(Push segue) , but when I pop to chat view and when pop back to list of dialogues it crashes

Did this work before? -- NO

Logs :---

*** -[QMChatIncomingCell release]: message sent to deallocated instance 0x7fc8cc4f6b60
screen shot 2016-06-10 at 5 25 22 pm

Crashing when loading nib of QMChatViewController from subclassed viewcontroller

Help avoid duplicate issue reports, check existing issues

Environment details
iOS version, Quickblox iOS SDK version, QMChatViewController version
I'm using this with swift 2.3 xcode 8 - I'm using the latest version of Quickblox and QMChatViewController

Did this work before?
No

Expected behavior
Can't load QMChatViewController

Actual behavior
I get a crash everytime when I try to load the nib.

'NSInvalidArgumentException', reason: 'NSLayoutConstraint for <QMInputToolbar: 0x7f970a6cb750; baseClass = UIToolbar; frame = (0 524; 320 44); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x600000023120>>: A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant. Location attributes must be specified in pairs.'

Logs
Attach full logs that will describe your problem (please, use github gist)
https://gist.github.com/anonymous/5232001f339ff0d2cb5edddd303d993e

Steps to reproduce the behavior

running on swift
Any others comments?
no

QMChatControlller Not Showing the Received Attachments ??

i am using QMChatViewController
In Chat Did received Message , i am Doing This .... i don't know actually how do i receive attachments and how can i display it using QMChatViewController;

When I add Message , It Doesn't Show up the image its Displays Only Blank Cell .

for(QBChatAttachment *attachment in message.attachments){
        // download file by ID
        [QBRequest downloadFileWithID:[attachment.ID integerValue] successBlock:^(QBResponse *response, NSData *fileData) {

            //UIImage *image = [UIImage imageWithData:fileData];

            QBChatMessage *message1 = [QBChatMessage message];

            QBChatAttachment *attachment1 = QBChatAttachment.new;
            attachment1.type = @"image/png";
            attachment1.url=attachment.url;


             [message1 setAttachments:@[attachment]];
            message1.dateSent = message.dateSent;

            [self.chatSectionManager addMessage:message1];



            return;

        } statusBlock:^(QBRequest *request, QBRequestStatus *status) {
            // handle progress
        } errorBlock:^(QBResponse *response) {
            NSLog(@"error: %@", response.error);
        }];
    }

When i Directly add the Received message in ChatSection Manager using this Code
[self.chatSectionManager addMessage:message1];

Still i m Getting the Same Result ..

Pods are not installed correctly

I just ran pod install and the project (workspace) looks like that (see screenshot). I can not run it or even see source files (only in .xproject)

screen shot 2016-09-29 at 12 04 45
Help avoid duplicate issue reports, check existing issues

Environment details
iOS version, Quickblox iOS SDK version, QMChatViewController version

Did this work before?

Expected behavior

Actual behavior

Logs
Attach full logs that will describe your problem (please, use github gist)

Steps to reproduce the behavior

Any others comments?

Anyway to override the colors of the long press on chat cells?

In the demo swift app as well as the app that I'm writing, when you hold your finger over the cells for a second or so, they turn gray or green. I'm wondering if there is a simple way to turn this off or to change the colors. I've been digging in the code and haven't had any luck yet.

Thanks.

newToolbarBottomLayoutGuideConstant is wrong when using with tabbar

Environment details
QMChatViewController (0.4.0.1)
QMServices (0.4.5)
QuickBlox (2.9)

Did this work before?
No idea

Expected behavior
It must be calculated with an optional toolbar height parameter or something like bottomContentAdditionalInset

Actual behavior
newToolbarBottomLayoutGuideConstant = CGRectGetHeight([UIScreen mainScreen].bounds) - CGRectGetMinY(superViewFrame);

How to load the messages in the correct order using QMChatSectionManager.

Hi,
I am using the UItableview for loading the chat messages. The messages are loading in reverse order.when new message is sending it is displaying in top of all messages. I used the code like below.

//.h
@property (strong, nonatomic) QMChatSectionManager *sectionmanager;

//ViewDidload
 sectionmanager=[QMChatSectionManager new];

    [[ServicesManager instance].chatService addDelegate:self];
    [ServicesManager instance].chatService.chatAttachmentService.delegate = self;

    if ([[self storedMessages] count] > 0 && sectionmanager.totalMessagesCount == 0) {
        // inserting all messages from memory storage
        NSLog(@"THE MESSAGES ARE %@",[self storedMessages]);
        [sectionmanager addMessages:[self storedMessages]];
        [chattingTable reloadData];
    }
    [self refreshMessagesShowingProgress:NO];
/////////////
- (void)refreshAndReadMessages; {

    [self refreshMessagesShowingProgress:YES];

    [self readMessages:self.unreadMessages];
    self.unreadMessages = nil;
    [chattingTable reloadData];

}
/////////////////
- (NSArray *)storedMessages
{
    return [[ServicesManager instance].chatService.messagesMemoryStorage messagesWithDialogID:self.dialog.ID];
}
//Number of sections
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return sectionmanager.chatSectionsCount;
}
//Number of Rows in section
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [sectionmanager messagesCountForSectionAtIndex:section];
  }

////cell for row
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIDentifier=@"cell";

    ChatDetailCell *cell=(ChatDetailCell *)[tableView dequeueReusableCellWithIdentifier:cellIDentifier];
    if(cell==nil)
    {
        [[NSBundle mainBundle] loadNibNamed:@"ChatDetailCell" owner:self options:nil];
        cell=self.chatCell;
    }
    NSUInteger lastSection = sectionmanager.chatSectionsCount - 1;
    if (indexPath.section == lastSection && indexPath.item == [sectionmanager messagesCountForSectionAtIndex:lastSection] - 1) {
        // the very first message
        // load more if exists
        // Getting earlier messages for chat dialog identifier.
        [[[ServicesManager instance].chatService loadEarlierMessagesWithChatDialogID:self.dialog.ID] continueWithBlock:^id(BFTask *task) {

            if ([task.result count] > 0) {
                [sectionmanager addMessages:task.result];
            }
            return nil;
        }];
    }
    // marking message as read if needed
    QBChatMessage *message = [sectionmanager messageForIndexPath:indexPath];
    [self sendReadStatusForMessage:message];
     cell. msglbl.text=message.text;
        //loading cell
return cell;
}

How to remove the bubble?

As the title said, I want to remove the bubble image in chat view. How to do that, is there any variable to disable that?

Thanks for attention!

13 error in QMServicesDevelopment.framework

ld: warning: directory not found for option '-F/Users/slk039/Desktop/QuickBlox_VideoCalling_Timer/Quickblox_Videocall_Swift/Pods/../../Framework'
ld: warning: directory not found for option '-F/Users/slk039/Desktop/QuickBlox_VideoCalling_Timer/Quickblox_Videocall_Swift/Pods/../External'

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_QBChat", referenced from:
objc-class-ref in QMChatService+Bolts.o
objc-class-ref in QMChatService.o
objc-class-ref in QMContactListService+Bolts.o
objc-class-ref in QMContactListService.o
objc-class-ref in QMUsersService.o
"OBJC_CLASS$_QBChatAttachment", referenced from:
objc-class-ref in CDAttachment.o
objc-class-ref in QMChatAttachmentService.o
"OBJC_CLASS$_QBChatDialog", referenced from:
objc-class-ref in CDDialog.o
objc-class-ref in QBChatMessage+QMCustomParameters.o
objc-class-ref in QMChatService.o
"OBJC_CLASS$QBChatMessage", referenced from:
objc-class-ref in CDMessage.o
l_OBJC
$CATEGORY_QBChatMessage$QMCustomParameters in QBChatMessage+QMCustomParameters.o
l_OBJC
$CATEGORY_QBChatMessage$_TextEncoding in QBChatMessage+TextEncoding.o
objc-class-ref in QMChatService.o
"OBJC_CLASS$_QBContactListItem", referenced from:
objc-class-ref in CDContactListItem.o
"OBJC_CLASS$_QBGeneralResponsePage", referenced from:
objc-class-ref in QMUsersService.o
"OBJC_CLASS$_QBMulticastDelegate", referenced from:
objc-class-ref in QMAuthService.o
objc-class-ref in QMChatService.o
objc-class-ref in QMContactListService.o
objc-class-ref in QMUsersService.o
"OBJC_CLASS$_QBRequest", referenced from:
objc-class-ref in QMAuthService.o
objc-class-ref in QMChatAttachmentService.o
objc-class-ref in QMChatService+Bolts.o
objc-class-ref in QMChatService.o
objc-class-ref in QMUsersService.o
"OBJC_CLASS$_QBResponsePage", referenced from:
objc-class-ref in QMChatService+Bolts.o
objc-class-ref in QMChatService.o
"OBJC_CLASS$_QBSession", referenced from:
objc-class-ref in QMAuthService.o
objc-class-ref in QMChatService.o
objc-class-ref in QMServicesManager.o
"OBJC_CLASS$_QBSettings", referenced from:
objc-class-ref in QMChatService+Bolts.o
objc-class-ref in QMChatService.o
"OBJC_CLASS$QBUUser", referenced from:
objc-class-ref in CDUser.o
l_OBJC
$CATEGORY_QBUUser$QMAssociatedObject in QBUUser+CustomData.o
l_OBJC
$CATEGORY_QBUUser$_CustomData in QBUUser+CustomData.o
objc-class-ref in QMChatService.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

QMCollectionView

How to get item index when i tap on a cell that contain image, i want to get this image to show in a pop up. and i using did select item at index path method but this method didn't call.

How to adjust the alignment of emojis after sending the text.

Hi,
When emojis are given after entering the text, space is displaying after emojis .how to adjust the alignment. this is occurring in the sample also . and container size is not adjusting when large text is give it comes on the other cell. below is the screenshot

screen shot 2016-03-31 at 6 51 02 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.