Giter VIP home page Giter VIP logo

quickblox / q-municate-services-ios Goto Github PK

View Code? Open in Web Editor NEW
31.0 18.0 42.0 18.42 MB

Easy-to-use services for Quickblox SDK, for speeding up development of iOS chat applications

License: BSD 3-Clause "New" or "Revised" License

Objective-C 99.12% Ruby 0.47% Shell 0.23% C 0.18%
quickblox easy cache services chat auth users pushnotificaitions contacts groupchat dialog objective-c ios

q-municate-services-ios's Introduction

QMServices are deprecated and won't be supported.

CocoaPods CocoaPods CocoaPods

QMServices

Easy-to-use services for Quickblox SDK, for speeding up development of iOS chat applications.

Features

  • High level API for Chat features including authentication service for logging to Quickblox REST and XMPP
  • Inbox persistent storage for messages, dialogs and users
  • Inbox memory storage for messages, dialogs and users
  • Bolts version of all methods. See [Bolts-iOS](https://github.com/BoltsFramework/Bolts-iOS "Bolts-iOS"") for more information.

Requirements

  • Xcode 6+
  • ARC

Dependencies

Installation

There are several ways to add QMServices to your project. They are described below:

1. Cocoapods

You can install QMServices using Cocoapods just by adding following line in your Podfile:

pod 'QMServices'

2. Using an Xcode subproject

Xcode sub-projects allow your project to use and build QMServices as an implicit dependency.

Add QMServices to your project as a Git submodule:

$ cd MyXcodeProjectFolder
$ git submodule add https://github.com/QuickBlox/q-municate-services-ios.git Vendor/QMServices
$ git commit -m "Added QMServices submodule"

This will add QMServices as a submodule and download Bolts as dependency. Drag Vendor/QMServices/QMServices.xcodeproj into your existing Xcode project.

Navigate to your project's settings, then select the target you wish to add QMServices to.

Navigate to Build Settings, then search for Header Search Paths and double-click it to edit

Add a new item using +: "$(SRCROOT)/Vendor/QMServices" and ensure that it is set to recursive

Navigate to Build Settings, then search for Framework Search Paths and double-click it to edit

Add a new item using +: "$(SRCROOT)/Vendor/QMServices/Frameworks"

** NOTE**

Only for manual installation: if you do not follow the steps below you will get compiler errors that Quickblox.framework and Bolts.framework are not found

Quickblox.framework and Bolts.framework in `"$(SRCROOT)/Vendor/QMServices/Frameworks"` does NOT contain binary data, they used only for generating bundles.
If you plan to use QMServices as sub-project, then
1. Download Quickblox.framework https://github.com/QuickBlox/quickblox-ios-sdk/archive/master.zip
2. Download Bolts.framework https://github.com/BoltsFramework/Bolts-ObjC/releases/download/1.5.1/Bolts-iOS.zip
3. Put the frameworks in the folder 'Vendor/QMServices/Frameworks'

** NOTE**: By default, QMServices subprojects reference Quickblox and Bolts frameworks at ../Frameworks. To change the path, you need to open Quickblox.xcconfig file and replace ../Frameworks with your path to the Quickblox.framework and Bolts.framework.

** NOTE** Please be aware that if you've set Xcode's Link Frameworks Automatically to No then you may need to add the Quickblox.framework, CoreData.framework to your project on iOS, as UIKit does not include Core Data by default. On OS X, Cocoa includes Core Data.

Now navigate to QMServices.xcodeproj subproject, open Build Settings, search for Framework Search Paths and locate Quickblox and Bolts frameworks folder there. Remember, that you have to link QMServices in Target Dependencies and (or) libQMServices.a in Link Binary with Libraries. Don't forget to add Quickblox and Bolts frameworks to your project.

Next step is to copy all bundles into your Copy bundle resources in Build Phases tab of your project settings. Navigate to QMServices.xcodeproj/Cache and move QMUsersCacheModel.bundle, QMContactListCacheModel.bundle and QMChatCacheModel.bundle that are existent in its subprojects to Copy Bundle Resources of your project. In a pop-up window select only "Create folder references".

If you are adding QMServices to the Swift project, you need to import them in your bridging header:

#import "QMServices.h"

To integrate Quckblox iOS SDK into your Swift project see our detailed guide here.

If you are still experiencing some crashes, check if you have set up correct Other linker flags for your project (-lxml2, -ObjC, -lstdc++) otherwise feel free to create an issue and let us know your problem.

Bundle generation

NOTE: You can skip this step if you do not use dialogs, messages and users memory and disc storage.

Bundle allows to pass .xcdatamodel file together with static library so it is required for QMChatCache and QMContactListCache projects.

To generate bundle for contact list you need to open QMServices project, navigate to Cache folder and select QMContactListCache.xcodeproj. Open project folder - you will see red QMContactListCacheModel.bundle. To create it select scheme QMContactListCacheModel and run it. After successful build QMContactListCacheModel.bundle color will change to black and you will be able to copy it to the project that uses QMServices. Include this bundle in your project.

To generate bundle for dialogs and messages you need to open QMServices project, navigate to Cache folder and select QMChatCache.xcodeproj. Open project folder - you will see red QMChatCacheModel.bundle. To create it select scheme QMChatCacheModel and run it. After successful build QMChatCacheModel.bundle` color will change to black and you will be able to copy it to the project that uses QMServices. Include this bundle in your project.

Architecture

QMServices contain:

  • QMAuthService
  • QMChatService
  • QMContactListService
  • QMUsersService

They all inherited from QMBaseService. To support CoreData caching you can use QMContactListCache, QMChatCache and QMUsersCache, which are inherited from QMDBStorage. Of course you could use your own database storage - just need to implement QMChatServiceDelegate, QMContactListServiceDelegate or QMUsersServiceDelegate depending on your needs.

Getting started

Add #import <QMServices.h> to your app's .pch file.

Service Manager

To start using services you could either use existing QMServicesManager class or create a subclass from it. Detailed explanation of the QMServicesManager class is below.

QMServicesManager has 2 functions - user login(login to REST API, chat)/logout(Logging out from chat, REST API, clearing persistent and memory cache) and establishing connection between QMChatCache and QMChatService to enable storing dialogs and messages data on disc.

Here is QMServicesManager.h:

@interface QMServicesManager : NSObject <QMServiceManagerProtocol, QMChatServiceCacheDataSource, QMChatServiceDelegate, QMChatConnectionDelegate>

+ (instancetype)instance;

- (void)logInWithUser:(QBUUser *)user completion:(void (^)(BOOL success, NSString *errorMessage))completion;
- (void)logoutWithCompletion:(dispatch_block_t)completion;

@property (nonatomic, readonly) QMAuthService* authService;
@property (nonatomic, readonly) QMChatService* chatService;

@end

And extension in QMServicesManager.m:

@interface QMServicesManager ()

@property (nonatomic, strong) QMAuthService* authService;
@property (nonatomic, strong) QMChatService* chatService;

@property (nonatomic, strong) dispatch_group_t logoutGroup;

@end

In init method, services and cache are initialised.

- (instancetype)init {
	self = [super init];
	if (self) {
		[QMChatCache setupDBWithStoreNamed:@"sample-cache"];
		[QMChatCache instance].messagesLimitPerDialog = 10;

		_authService = [[QMAuthService alloc] initWithServiceManager:self];
		_chatService = [[QMChatService alloc] initWithServiceManager:self cacheDataSource:self];
		[_chatService addDelegate:self];
		_logoutGroup = dispatch_group_create();
	}
	return self;
}
  • Cache setup (You could skip it if you don't need persistent storage).

    • Initiates Core Data database for dialog and messages:
     [QMChatCache setupDBWithStoreNamed:@"sample-cache"];
  • Services setup

    • Authentication service:
     _authService = [[QMAuthService alloc] initWithServiceManager:self];
    • Chat service (responsible for establishing chat connection and responding to chat events (message, presences and so on)):
     _chatService = [[QMChatService alloc] initWithServiceManager:self cacheDataSource:self];

Also you have to implement QMServiceManagerProtocol methods:

- (void)handleErrorResponse:(QBResponse *)response {
	// handle error response from services here
}

- (BOOL)isAuthorized {
	return self.authService.isAuthorized;
}

- (QBUUser *)currentUser {
	return [QBSession currentSession].currentUser;
}

To implement chat messages and dialogs caching you should implement following methods from QMChatServiceDelegate protocol:

- (void)chatService:(QMChatService *)chatService didAddChatDialogToMemoryStorage:(QBChatDialog *)chatDialog {
	[QMChatCache.instance insertOrUpdateDialog:chatDialog completion:nil];
}

- (void)chatService:(QMChatService *)chatService didAddChatDialogsToMemoryStorage:(NSArray *)chatDialogs {
	[QMChatCache.instance insertOrUpdateDialogs:chatDialogs completion:nil];
}

- (void)chatService:(QMChatService *)chatService didAddMessageToMemoryStorage:(QBChatMessage *)message forDialogID:(NSString *)dialogID {
	[QMChatCache.instance insertOrUpdateMessage:message withDialogId:dialogID completion:nil];
}

- (void)chatService:(QMChatService *)chatService didAddMessagesToMemoryStorage:(NSArray *)messages forDialogID:(NSString *)dialogID {
	[QMChatCache.instance insertOrUpdateMessages:messages withDialogId:dialogID completion:nil];
}

- (void)chatService:(QMChatService *)chatService didDeleteChatDialogWithIDFromMemoryStorage:(NSString *)chatDialogID {
    [QMChatCache.instance deleteDialogWithID:chatDialogID completion:nil];
}

- (void)chatService:(QMChatService *)chatService  didReceiveNotificationMessage:(QBChatMessage *)message createDialog:(QBChatDialog *)dialog {
	[QMChatCache.instance insertOrUpdateMessage:message withDialogId:dialog.ID completion:nil];
	[QMChatCache.instance insertOrUpdateDialog:dialog completion:nil];
}

- (void)chatService:(QMChatService *)chatService didUpdateChatDialogInMemoryStorage:(QBChatDialog *)chatDialog {
    [[QMChatCache instance] insertOrUpdateDialog:chatDialog completion:nil];
}

Also for prefetching initial dialogs and messages you have to implement QMChatServiceCacheDataSource protocol:

- (void)cachedDialogs:(QMCacheCollection)block {
	[QMChatCache.instance dialogsSortedBy:CDDialogAttributes.lastMessageDate ascending:YES completion:^(NSArray *dialogs) {
		block(dialogs);
	}];
}

- (void)cachedMessagesWithDialogID:(NSString *)dialogID block:(QMCacheCollection)block {
	[QMChatCache.instance messagesWithDialogId:dialogID sortedBy:CDMessageAttributes.messageID ascending:YES completion:^(NSArray *array) {
		block(array);
	}];
}

Logs

By default QMServices logging its information in developer console. You may want to disable them (for example for production, logs can slow your app sometimes). In order to do so use QMServicesManager static method:

+ (void)enableLogging:(BOOL)flag;

Just set it, for example, in your AppDelegate class like this:

[QMServicesManager enableLogging:NO];

Authentication

Login

This method logins user to Quickblox REST API backend and to the Quickblox Chat backend. Also it automatically tries to join to all cached group dialogs - to immediately receive incomming messages.

- (void)logInWithUser:(QBUUser *)user
		   completion:(void (^)(BOOL success, NSString *errorMessage))completion
{
	__weak typeof(self) weakSelf = self;
	[self.authService logInWithUser:user completion:^(QBResponse *response, QBUUser *userProfile) {
		if (response.error != nil) {
			if (completion != nil) {
				completion(NO, response.error.error.localizedDescription);
			}
			return;
		}
		
		[weakSelf.chatService connectWithCompletionBlock:^(NSError * _Nullable error) {
            //
            __typeof(self) strongSelf = weakSelf;
            
            [strongSelf.chatService loadCachedDialogsWithCompletion:^{
                NSArray* dialogs = [strongSelf.chatService.dialogsMemoryStorage unsortedDialogs];
                for (QBChatDialog* dialog in dialogs) {
                    if (dialog.type != QBChatDialogTypePrivate) {
                        [strongSelf.chatService joinToGroupDialog:dialog completion:^(NSError * _Nullable error) {
                            //
                            if (error != nil) {
                                NSLog(@"Join error: %@", error.localizedDescription);
                            }
                        }];
                    }
                }
                
                if (completion != nil) {
                    completion(error == nil, error.localizedDescription);
                }
                
            }];
        }];
	}];
}

Example of usage:

    // Logging in to Quickblox REST API and chat.
    [QMServicesManager.instance logInWithUser:selectedUser completion:^(BOOL success, NSString *errorMessage) {
        if (success) {
            // Handle success login
        } else {
            // Handle error with error message
        }
    }];

Logout

- (void)logoutWithCompletion:(dispatch_block_t)completion
{
    if ([QBSession currentSession].currentUser != nil) {
        __weak typeof(self)weakSelf = self;
                
        dispatch_group_enter(self.logoutGroup);
        [self.authService logOut:^(QBResponse *response) {
            __typeof(self) strongSelf = weakSelf;
            [strongSelf.chatService disconnectWithCompletionBlock:nil];
            [strongSelf.chatService free];
            dispatch_group_leave(strongSelf.logoutGroup);
        }];
        
        dispatch_group_enter(self.logoutGroup);
        [[QMChatCache instance] deleteAllDialogsWithCompletion:^{
            __typeof(self) strongSelf = weakSelf;
            dispatch_group_leave(strongSelf.logoutGroup);
        }];
        
        dispatch_group_enter(self.logoutGroup);
        [[QMChatCache instance] deleteAllMessagesWithCompletion:^{
            __typeof(self) strongSelf = weakSelf;
            dispatch_group_leave(strongSelf.logoutGroup);
        }];
        
        dispatch_group_notify(self.logoutGroup, dispatch_get_main_queue(), ^{
            if (completion) {
                completion();
            }
        });
    } else {
        if (completion) {
            completion();
        }
    }
}

Example of usage:

    [[QMServicesManager instance] logoutWithCompletion:^{
        // Handle logout
    }];

Fetching chat dialogs

Load all dialogs from REST API:

Extended request parameters could be taken from http://quickblox.com/developers/SimpleSample-chat_users-ios#Filters.

[QMServicesManager.instance.chatService allDialogsWithPageLimit:100 extendedRequest:nil iterationBlock:^(QBResponse *response, NSArray *dialogObjects, NSSet *dialogsUsersIDs, BOOL *stop) {
	// reload UI, this block is called when page is loaded
} completion:^(QBResponse *response) {
	// loading finished, all dialogs fetched
}];

These dialogs are automatically stored in QMDialogsMemoryStorage class.

Fetching chat messages

Fetching messages from REST API history:

[QMServicesManager instance].chatService messagesWithChatDialogID:@"53fdc87fe4b0f91d92fbb27e" completion:^(QBResponse *response, NSArray *messages) {
	// update UI, handle messages
}];

These message are automatically stored in QMMessagesMemoryStorage class.

Sending message

Send message to dialog:

QBChatMessage *message = [QBChatMessage message];
message.text = @"Awesome text";
message.senderID = 2308497;

[[QMServicesManager instance].chatService sendMessage:message type:QMMessageTypeText toDialogId:@"53fdc87fe4b0f91d92fbb27e" saveToHistory:YES saveToStorage:YES completion:nil];

Message is automatically added to QMMessagesMemoryStorage class.

Fetching users

[[[QMServicesManager instance].usersService getUsersWithIDs:@[@(2308497), @(2308498)]] continueWithBlock:^id(BFTask<NSArray<QBUUser *> *> *task) {
        if (task.error == nil) {
            // handle users
        }
        return nil;
}];

Users are automatically stored in QMUsersMemoryStorage class.

Subclass of QMServicesManager example

This example adds additional functionality - storing of users in contact list cache, error handling, storing currently opened dialog identifier.

Header file:

@interface ServicesManager : QMServicesManager <QMContactListServiceCacheDataSource>

// Replaces with any users service you are already using or going to use
@property (nonatomic, readonly) UsersService* usersService;

@property (nonatomic, strong) NSString* currentDialogID;

@end

Implementation file:

@interface ServicesManager ()

@property (nonatomic, strong) QMContactListService* contactListService;

@end

@implementation ServicesManager

- (instancetype)init {
	self = [super init];
    
	if (self) {
        [QMContactListCache setupDBWithStoreNamed:kContactListCacheNameKey];
		_contactListService = [[QMContactListService alloc] initWithServiceManager:self cacheDataSource:self];
		// Replace with any users service you are already using or going to use
		_usersService = [[UsersService alloc] initWithContactListService:_contactListService];
	}
    
	return self;
}

- (void)showNotificationForMessage:(QBChatMessage *)message inDialogID:(NSString *)dialogID
{
    if ([self.currentDialogID isEqualToString:dialogID]) return;
    
    if (message.senderID == self.currentUser.ID) return;
    
    NSString* dialogName = @"New message";
    
    QBChatDialog* dialog = [self.chatService.dialogsMemoryStorage chatDialogWithID:dialogID];
    
    if (dialog.type != QBChatDialogTypePrivate) {
        dialogName = dialog.name;
    } else {
        QBUUser* user = [[StorageManager instance] userByID:dialog.recipientID];
        if (user != nil) {
            dialogName = user.login;
        }
    }
    
    // Display notification UI
}

- (void)handleErrorResponse:(QBResponse *)response {
    
    [super handleErrorResponse:response];
    
    if (![self isAuthorized]) return;
	NSString *errorMessage = [[response.error description] stringByReplacingOccurrencesOfString:@"(" withString:@""];
	errorMessage = [errorMessage stringByReplacingOccurrencesOfString:@")" withString:@""];
	
	if( response.status == 502 ) { // bad gateway, server error
		errorMessage = @"Bad Gateway, please try again";
	}
	else if( response.status == 0 ) { // bad gateway, server error
		errorMessage = @"Connection network error, please try again";
	}
    
    // Display notification UI
}

#pragma mark QMChatServiceCache delegate

- (void)chatService:(QMChatService *)chatService didAddMessageToMemoryStorage:(QBChatMessage *)message forDialogID:(NSString *)dialogID {
    [super chatService:chatService didAddMessageToMemoryStorage:message forDialogID:dialogID];
    
    [self showNotificationForMessage:message inDialogID:dialogID];
}

#pragma mark QMContactListServiceCacheDelegate delegate

- (void)cachedUsers:(QMCacheCollection)block {
	[QMContactListCache.instance usersSortedBy:@"id" ascending:YES completion:block];
}

- (void)cachedContactListItems:(QMCacheCollection)block {
	[QMContactListCache.instance contactListItems:block];
}

@end

QMAuthService

This class is responsible for authentication operations.

Current user authorisation status:

@property (assign, nonatomic, readonly) BOOL isAuthorized;

Sign up user and login to Quickblox.

- (QBRequest *)signUpAndLoginWithUser:(QBUUser *)user completion:(void(^)(QBResponse *response, QBUUser *userProfile))completion;

Login user to Quickblox.

- (QBRequest *)logInWithUser:(QBUUser *)user completion:(void(^)(QBResponse *response, QBUUser *userProfile))completion;

Login with facebook session token.

- (QBRequest *)logInWithFacebookSessionToken:(NSString *)sessionToken completion:(void(^)(QBResponse *response, QBUUser *userProfile))completion;

Logout user from Quickblox.

- (QBRequest *)logInWithFacebookSessionToken:(NSString *)sessionToken completion:(void(^)(QBResponse *response, QBUUser *userProfile))completion;

QMAuthService + Bolts

QMAuthService also has all methods implemented using BFTasks.

Sign up user and log's in to Quickblox using Bolts.

- (BFTask *)signUpAndLoginWithUser:(QBUUser *)user;

Login user to Quickblox using Bolts.

- (BFTask *)loginWithUser:(QBUUser *)user;

Login with facebook session token using Bolts.

- (BFTask *)loginWithFacebookSessionToken:(NSString *)sessionToken;

Logout user from Quickblox using Bolts.

- (BFTask *)logout;

QMChatService

This class is responsible for operation with messages and dialogs.

Connect user to Quickblox chat.

- (void)connectWithCompletionBlock:(QBChatCompletionBlock)completion;

Disconnect user from Quickblox chat.

- (void)disconnectWithCompletionBlock:(QBChatCompletionBlock)completion;

Join user to group dialog.

- (void)joinToGroupDialog:(QBChatDialog *)dialog completion:(QBChatCompletionBlock)completion;

Create group chat dialog with occupants on Quickblox.

- (void)createGroupChatDialogWithName:(NSString *)name photo:(NSString *)photo occupants:(NSArray *)occupants
completion:(void(^)(QBResponse *response, QBChatDialog *createdDialog))completion;

Create private chat dialog with opponent on Quickblox.

- (void)createPrivateChatDialogWithOpponent:(QBUUser *)opponent
completion:(void(^)(QBResponse *response, QBChatDialog *createdDialog))completion;

Change dialog name.

- (void)changeDialogName:(NSString *)dialogName forChatDialog:(QBChatDialog *)chatDialog
completion:(void(^)(QBResponse *response, QBChatDialog *updatedDialog))completion;

Change dialog avatar.

- (void)changeDialogAvatar:(NSString *)avatarPublicUrl forChatDialog:(QBChatDialog *)chatDialog
completion:(void(^)(QBResponse *response, QBChatDialog *updatedDialog))completion;

Add occupants to dialog.

- (void)joinOccupantsWithIDs:(NSArray *)ids toChatDialog:(QBChatDialog *)chatDialog
completion:(void(^)(QBResponse *response, QBChatDialog *updatedDialog))completion;

Deletes dialog on service and in cache.

- (void)deleteDialogWithID:(NSString *)dialogId
completion:(void(^)(QBResponse *response))completion;

Recursively fetch all dialogs from Quickblox.

- (void)allDialogsWithPageLimit:(NSUInteger)limit
				extendedRequest:(NSDictionary *)extendedRequest
				 iterationBlock:(void(^)(QBResponse *response, NSArray *dialogObjects, NSSet *dialogsUsersIDs, BOOL *stop))iterationBlock
					 completion:(void(^)(QBResponse *response))completion;

Send system message to users about adding to dialog with dialog inside.

- (void)sendSystemMessageAboutAddingToDialog:(QBChatDialog *)chatDialog
                                  toUsersIDs:(NSArray *)usersIDs
                                  completion:(QBChatCompletionBlock)completion;

Send message about updated dialog with dialog inside and notification.

- (void)sendMessageAboutUpdateDialog:(QBChatDialog *)updatedDialog
                withNotificationText:(NSString *)notificationText
                    customParameters:(NSDictionary *)customParameters
                          completion:(QBChatCompletionBlock)completion;

Send message about accepting or rejecting contact requst.

- (void)sendMessageAboutAcceptingContactRequest:(BOOL)accept
                                   toOpponentID:(NSUInteger)opponentID
                                     completion:(QBChatCompletionBlock)completion;

Sending notification message about adding occupants to specific dialog.

- (void)sendNotificationMessageAboutAddingOccupants:(NSArray *)occupantsIDs
                                           toDialog:(QBChatDialog *)chatDialog
                               withNotificationText:(NSString *)notificationText
                                         completion:(QBChatCompletionBlock)completion;
                                         

Sending notification message about leaving dialog.

- (void)sendNotificationMessageAboutLeavingDialog:(QBChatDialog *)chatDialog
                             withNotificationText:(NSString *)notificationText
                                       completion:(QBChatCompletionBlock)completion;
                                         

Sending notification message about changing dialog photo.

- (void)sendNotificationMessageAboutChangingDialogPhoto:(QBChatDialog *)chatDialog
                                   withNotificationText:(NSString *)notificationText
                                             completion:(QBChatCompletionBlock)completion;
                                         

Sending notification message about changing dialog name.

- (void)sendNotificationMessageAboutChangingDialogName:(QBChatDialog *)chatDialog
                                  withNotificationText:(NSString *)notificationText
                                            completion:(QBChatCompletionBlock)completion;
                                         

Fetches 100 messages starting from latest message in cache.

- (void)messagesWithChatDialogID:(NSString *)chatDialogID completion:(void(^)(QBResponse *response, NSArray *messages))completion;

Fetches 100 messages that are older than oldest message in cache.

- (BFTask <NSArray <QBChatMessage *> *> *)loadEarlierMessagesWithChatDialogID:(NSString *)chatDialogID;

Fetch dialog with dialog identifier.

- (void)fetchDialogWithID:(NSString *)dialogID completion:(void (^)(QBChatDialog *dialog))completion;

Load dialog with dialog identifier from Quickblox server and save to local storage.

- (void)loadDialogWithID:(NSString *)dialogID completion:(void (^)(QBChatDialog *loadedDialog))completion;

Fetch dialogs updated from date.

- (void)fetchDialogsUpdatedFromDate:(NSDate *)date
 					   andPageLimit:(NSUInteger)limit
 					 iterationBlock:(void(^)(QBResponse *response, NSArray *dialogObjects, NSSet *dialogsUsersIDs, BOOL *stop))iteration
 					completionBlock:(void (^)(QBResponse *response))completion;

Send message to dialog.

- (void)sendMessage:(QBChatMessage *)message
		   toDialog:(QBChatDialog *)dialog
      saveToHistory:(BOOL)saveToHistory
      saveToStorage:(BOOL)saveToStorage
         completion:(QBChatCompletionBlock)completion;

Send attachment message to dialog.

- (void)sendAttachmentMessage:(QBChatMessage *)attachmentMessage
                     toDialog:(QBChatDialog *)dialog
          withAttachmentImage:(UIImage *)image
                   completion:(QBChatCompletionBlock)completion;

Mark message as delivered.

- (void)markMessageAsDelivered:(QBChatMessage *)message completion:(QBChatCompletionBlock)completion;

Mark messages as delivered.

- (void)markMessagesAsDelivered:(NSArray<QBChatMessage *> *)messages completion:(QBChatCompletionBlock)completion;

Send read status for message and update unreadMessageCount for dialog in storage.

- (void)readMessage:(QBChatMessage *)message completion:(QBChatCompletionBlock)completion;

Send read status for messages and update unreadMessageCount for dialog in storage.

- (void)readMessages:(NSArray<QBChatMessage *> *)messages forDialogID:(NSString *)dialogID completion:(QBChatCompletionBlock)completion;

QMChatService + Bolts

QMChatService also has all methods implemented using BFTasks.

Connect user to Quickblox chat using Bolts.

- (BFTask *)connect;

Disconnect user from Quickblox chat using Bolts.

- (BFTask *)disconnect;

Join user to group dialog using Bolts.

- (BFTask *)joinToGroupDialog:(QBChatDialog *)dialog;

Create group chat dialog with occupants on Quickblox using Bolts.

- (BFTask *)createGroupChatDialogWithName:(NSString *)name photo:(NSString *)photo occupants:(NSArray *)occupants;

Create private chat dialog with opponent on Quickblox using Bolts.

- (BFTask *)createPrivateChatDialogWithOpponent:(QBUUser *)opponent;

Change dialog name using Bolts.

- (BFTask *)changeDialogName:(NSString *)dialogName forChatDialog:(QBChatDialog *)chatDialog;

Change dialog avatar using Bolts.

- (BFTask *)changeDialogAvatar:(NSString *)avatarPublicUrl forChatDialog:(QBChatDialog *)chatDialog;

Add occupants to dialog using Bolts.

- (BFTask *)joinOccupantsWithIDs:(NSArray *)ids toChatDialog:(QBChatDialog *)chatDialog;

Deletes dialog on service and in cache using Bolts.

- (BFTask *)deleteDialogWithID:(NSString *)dialogID;

Recursively fetch all dialogs from Quickblox using Bolts.

- (BFTask *)allDialogsWithPageLimit:(NSUInteger)limit
                    extendedRequest:(NSDictionary *)extendedRequest
                     iterationBlock:(void(^)(QBResponse *response, NSArray *dialogObjects, NSSet *dialogsUsersIDs, BOOL *stop))iterationBlock;

Send system message to users about adding to dialog with dialog inside using Bolts.

- (BFTask *)sendSystemMessageAboutAddingToDialog:(QBChatDialog *)chatDialog
                                      toUsersIDs:(NSArray *)usersIDs;

Send message about accepting or rejecting contact requst using Bolts.

- (BFTask *)sendMessageAboutAcceptingContactRequest:(BOOL)accept
                                       toOpponentID:(NSUInteger)opponentID;

Sending notification message about adding occupants to specific dialog using Bolts.

- (BFTask *)sendNotificationMessageAboutAddingOccupants:(NSArray *)occupantsIDs
                                               toDialog:(QBChatDialog *)chatDialog
                                   withNotificationText:(NSString *)notificationText;
                                         

Sending notification message about leaving dialog using Bolts.

- (BFTask *)sendNotificationMessageAboutLeavingDialog:(QBChatDialog *)chatDialog
                                 withNotificationText:(NSString *)notificationText;
                                         

Sending notification message about changing dialog photo using Bolts.

- (BFTask *)sendNotificationMessageAboutChangingDialogPhoto:(QBChatDialog *)chatDialog
                                       withNotificationText:(NSString *)notificationText;
                                         

Sending notification message about changing dialog name using Bolts.

- (BFTask *)sendNotificationMessageAboutChangingDialogName:(QBChatDialog *)chatDialog
                                      withNotificationText:(NSString *)notificationText;
                                         

Fetches messages with chat dialog ID using Bolts.

- (BFTask *)messagesWithChatDialogID:(NSString *)chatDialogID;

Fetch dialog with dialog identifier using Bolts.

- (BFTask *)fetchDialogWithID:(NSString *)dialogID;

Load dialog with dialog identifier from Quickblox server and save to local storage using Bolts.

- (BFTask *)loadDialogWithID:(NSString *)dialogID;

Fetch dialogs updated from date using Bolts.

- (BFTask *)fetchDialogsUpdatedFromDate:(NSDate *)date
                           andPageLimit:(NSUInteger)limit
                         iterationBlock:(void(^)(QBResponse *response, NSArray *dialogObjects, NSSet *dialogsUsersIDs, BOOL *stop))iteration;

Send message to dialog using Bolts.

- (BFTask *)sendMessage:(QBChatMessage *)message
               toDialog:(QBChatDialog *)dialog
          saveToHistory:(BOOL)saveToHistory
          saveToStorage:(BOOL)saveToStorage;

Send attachment message to dialog using Bolts.

- (BFTask *)sendAttachmentMessage:(QBChatMessage *)attachmentMessage
                         toDialog:(QBChatDialog *)dialog
              withAttachmentImage:(UIImage *)image;

Mark message as delivered using Bolts.

- (BFTask *)markMessageAsDelivered:(QBChatMessage *)message;

Send read status for message and update unreadMessageCount for dialog in storage using Bolts.

- (BFTask *)readMessage:(QBChatMessage *)message;

QMDialogsMemoryStorage

This class is responsible for in-memory dialogs storage.

Adds chat dialog and joins if chosen.

- (void)addChatDialog:(QBChatDialog *)chatDialog andJoin:(BOOL)join completion:(void(^)(QBChatDialog *addedDialog, NSError *error))completion;

Adds chat dialogs and joins.

- (void)addChatDialogs:(NSArray *)dialogs andJoin:(BOOL)join;

Deletes chat dialog.

- (void)deleteChatDialogWithID:(NSString *)chatDialogID;

Find dialog by identifier.

- (QBChatDialog *)chatDialogWithID:(NSString *)dialogID;

Find private chat dialog with opponent ID.

- (QBChatDialog *)privateChatDialogWithOpponentID:(NSUInteger)opponentID;

Find unread dialogs.

- (NSArray *)unreadDialogs;

Fetch all dialogs.

- (NSArray *)unsortedDialogs;

Fetch all dialogs sorted by last message date.

- (NSArray *)dialogsSortByLastMessageDateWithAscending:(BOOL)ascending;

Fetch all dialogs sorted by updated at.

- (NSArray *)dialogsSortByUpdatedAtWithAscending:(BOOL)ascending;

Fetch dialogs with specified sort descriptors.

- (NSArray *)dialogsWithSortDescriptors:(NSArray *)descriptors;

QMMessagesMemoryStorage

This class is responsible for in-memory messages storage.

Add message.

- (void)addMessage:(QBChatMessage *)message forDialogID:(NSString *)dialogID;

Add messages.

- (void)addMessages:(NSArray *)messages forDialogID:(NSString *)dialogID;

Replace all messages for dialog.

- (void)replaceMessages:(NSArray *)messages forDialogID:(NSString *)dialogID;

Update message.

- (void)updateMessage:(QBChatMessage *)message;

Fetch messages.

- (NSArray *)messagesWithDialogID:(NSString *)dialogID;

Delete messages for dialog.

- (void)deleteMessagesWithDialogID:(NSString *)dialogID;

Fetch message by identifier.

- (QBChatMessage *)messageWithID:(NSString *)messageID fromDialogID:(NSString *)dialogID;

Fetch last message.

- (QBChatMessage *)lastMessageFromDialogID:(NSString *)dialogID;

Checks if dialog has messages.

- (BOOL)isEmptyForDialogID:(NSString *)dialogID;

Fetch oldest(first) message.

- (QBChatMessage *)oldestMessageForDialogID:(NSString *)dialogID;

QMChatAttachmentService

This class is responsible for attachment operations (sending, receiving, loading, saving).

Attachment status delegate:

@property (nonatomic, weak) id<QMChatAttachmentServiceDelegate> delegate;

Get attachment image. (Download from Quickblox or load from disc).

- (void)getImageForAttachmentMessage:(QBChatMessage *)attachmentMessage completion:(void(^)(NSError *error, UIImage *image))completion;

QMContactListService

This class is responsible for contact list operations.

Add user to contact list.

- (void)addUserToContactListRequest:(QBUUser *)user completion:(void(^)(BOOL success))completion;

Remove user from contact list.

- (void)removeUserFromContactListWithUserID:(NSUInteger)userID completion:(void(^)(BOOL success))completion;

Accept contact request.

- (void)acceptContactRequest:(NSUInteger)userID completion:(void (^)(BOOL success))completion;

Reject contact request.

- (void)rejectContactRequest:(NSUInteger)userID completion:(void(^)(BOOL success))completion;

QMContactListMemoryStorage

This class is responsible for in-memory contact list storage.

Update contact list memory storage.

- (void)updateWithContactList:(QBContactList *)contactList;

Update contact list memory storage with array of contact list items.

- (void)updateWithContactList:(QBContactList *)contactList;

Fetch contact list item.

- (QBContactListItem *)contactListItemWithUserID:(NSUInteger)userID;

Fetch user ids from contact list memory storage.

- (NSArray *)userIDsFromContactList;

QMUsersService

This class is responsible for operations with users and uses BFTasks.

Load users to memory storage from disc cache.

- (BFTask<NSArray<QBUUser *> *> *)loadFromCache;

###Get users

There are several ways to get users by methods below. By default every get method first checking for a specific user in cache. If such user was found in cache method will exclude him from server request, and send request only for users, that weren't found in local cache. If you want to update users in cache, you need to force them to be loaded from server, even though they are already being cached. Every get method has also its implementation with forceLoad flag, set it to YES in order to force users loading from server.

Get user by id:

- (BFTask<QBUUser *> *)getUserWithID:(NSUInteger)userID;

Get users by ids:

- (BFTask<NSArray<QBUUser *> *> *)getUsersWithIDs:(NSArray<NSNumber *> *)usersIDs;

Get users by ids with extended pagination parameters:

- (BFTask<NSArray<QBUUser *> *> *)getUsersWithIDs:(NSArray<NSNumber *> *)usersIDs page:(QBGeneralResponsePage *)page;

Get users by emails:

- (BFTask<NSArray<QBUUser *> *> *)getUsersWithEmails:(NSArray<NSString *> *)emails;

Get users by emails with extended pagination parameters:

- (BFTask<NSArray<QBUUser *> *> *)getUsersWithEmails:(NSArray<NSString *> *)emails page:(QBGeneralResponsePage *)page;

Get users by facebook ids:

- (BFTask<NSArray<QBUUser *> *> *)getUsersWithFacebookIDs:(NSArray<NSString *> *)facebookIDs;

Get users by facebook ids with extended pagination parameters:

- (BFTask<NSArray<QBUUser *> *> *)getUsersWithFacebookIDs:(NSArray<NSString *> *)facebookIDs page:(QBGeneralResponsePage *)page;

Get users by logins:

- (BFTask<NSArray<QBUUser *> *> *)getUsersWithLogins:(NSArray<NSString *> *)logins;

Get users by logins with extended pagination parameters:

- (BFTask<NSArray<QBUUser *> *> *)getUsersWithLogins:(NSArray<NSString *> *)logins page:(QBGeneralResponsePage *)page;

###Search users

Search for users by full name:

- (BFTask<NSArray<QBUUser *> *> *)searchUsersWithFullName:(NSString *)searchText;

Search for users by full name with extended pagination parameters:

- (BFTask<NSArray<QBUUser *> *> *)searchUsersWithFullName:(NSString *)searchText page:(QBGeneralResponsePage *)page;

Search for users by tags:

- (BFTask<NSArray<QBUUser *> *> *)searchUsersWithTags:(NSArray<NSString *> *)tags;

Search for users by tags with extended pagination parameters:

- (BFTask<NSArray<QBUUser *> *> *)searchUsersWithTags:(NSArray<NSString *> *)tags page:(QBGeneralResponsePage *)page;

QMUsersMemoryStorage

This class is responsible for in-memory users storage.

Delegate for getting UsersMemoryStorage user ids.

@property (weak, nonatomic) id <QMUsersMemoryStorageDelegate> delegate;

Add users

Add user to memory storage.

- (void)addUser:(QBUUser *)user;

Add users to memory storage.

- (void)addUsers:(NSArray<QBUUser *> *)users;

Get users

Get all users from memory storage without sorting.

- (NSArray<QBUUser *> *)unsortedUsers;

Get all users in memory storage sorted by key.

- (NSArray<QBUUser *> *)usersSortedByKey:(NSString *)key ascending:(BOOL)ascending;

Get all contacts in memory storage sorted by key.

- (NSArray *)contactsSortedByKey:(NSString *)key ascending:(BOOL)ascending;

Get users with ids without some id.

- (NSArray<QBUUser *> *)usersWithIDs:(NSArray *)IDs withoutID:(NSUInteger)ID;

Get string created from users full names, separated by ",".

- (NSString *)joinedNamesbyUsers:(NSArray *)users;

Get user with user id.

- (QBUUser *)userWithID:(NSUInteger)userID;

Get users with user ids.

- (NSArray<QBUUser *> *)usersWithIDs:(NSArray *)ids;

Get users with user logins.

- (NSArray<QBUUser *> *)usersWithLogins:(NSArray<NSString *> *)logins;

Get users with user emails.

- (NSArray<QBUUser *> *)usersWithEmails:(NSArray<NSString *> *)emails;

Get users with user facebook ids.

- (NSArray<QBUUser *> *)usersWithFacebookIDs:(NSArray<NSString *> *)facebookIDs;

Search and Exclude

Search for users excluding users with users ids. Result dictionary will contain an array of found users, and an array of not found search criteria (ids, logins, emails etc).

- (NSDictionary *)usersByExcludingUsersIDs:(NSArray<NSNumber *> *)ids;

Search for users excluding users with logins.

- (NSDictionary *)usersByExcludingLogins:(NSArray<NSString *> *)logins;

Search for users excluding users with email.

- (NSDictionary *)usersByExcludingEmails:(NSArray<NSString *> *)emails;

Search for users excluding users with facebook IDs.

- (NSDictionary *)usersByExcludingFacebookIDs:(NSArray<NSString *> *)facebookIDs;

Documentation

For more information see our inline code documentation.

License

See LICENSE.txt

q-municate-services-ios's People

Contributors

forsarion avatar glebus avatar isevendays avatar joihelgi avatar ogrepet avatar pro100andrey avatar sshaforenkoqb avatar yakubbaev 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

Watchers

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

q-municate-services-ios's Issues

Can not install when install with use_frameworks command

I get this error when trying to install QuickBlox via Pod.
[!] The 'Pods' target has transitive dependencies that include static binaries: (/Users/TranNgocLinh88/Documents/Projects/My projects/ebutler_ios/eBulter_iOS/Pods/QuickBlox/Quickblox.framework)

Here is my pod file

inhibit_all_warnings!

platform :ios, '8.0'
use_frameworks!

pod 'PureLayout', '~> 2.0.4'
pod 'SVPullToRefresh', '~> 0.4'
pod 'SVProgressHUD', '~> 1.1'
pod 'AFNetworking', '~> 2.5'
pod 'IQKeyboardManager', '~> 3.3'
pod 'HCSStarRatingView', '~> 1.4'
pod 'FXPageControl', '~> 1.4'
pod 'GoogleMaps', '~> 1.11'
pod 'Fabric'
pod 'Crashlytics'
pod 'NSDate-Time-Ago', '~> 1.0'
pod 'SDWebImage', '~> 3.7'
pod 'MWPhotoBrowser', '~> 2.1'
pod 'DKImagePickerController', '~> 3.0'

#Chat Module
pod 'FontAwesome', '~> 4.3'
pod 'JDStatusBarNotification', '~> 1.5'
pod 'MessageDisplayKit', '~> 5.4'
pod 'QMServices'
pod 'Reachability', '~> 3.2'
pod 'UIImage+FixOrientation', '~> 1.0'

changeFramworks

Hi,

I am changing QuickBlox framework in my project to a new one but I have some issues,
what can I use instead of:

  • (QBRequest *)createSessionWithExtendedParameters:(QBSessionParameters *)extendedParameters successBlock:(void (^)(QBResponse *response, QBASession *session))successBlock errorBlock:(QBRequestErrorBlock)errorBlock;

or:

  • (QBRequest *)createSessionWithSuccessBlock:(void (^)(QBResponse *response, QBASession *session))successBlock errorBlock:(QBRequestErrorBlock)errorBlock;

Can not check out master

I'm using source tree and I can not check out branch master.
Here is the error:

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree reset -q --hard HEAD -- 


git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree checkout master 
Downloading Frameworks/Quickblox.framework/Versions/A/Quickblox (34.22 MB)
Error accessing media: Frameworks/Quickblox.framework/Versions/A/Quickblox (587687c7b20b58ce4f6ed3fd0048f04a1181d20c1638d8ed84665511c52518fe)

Errors logged to .git/lfs/objects/logs/20160216T143238.457527037.log
Use `git lfs logs last` to view the log.
error: external filter git-lfs smudge %f failed 2
error: external filter git-lfs smudge %f failed
fatal: Frameworks/Quickblox.framework/Versions/A/Quickblox: smudge filter lfs failed
Completed with errors, see above

I installed git-lfs
screen shot 2016-02-16 at 2 34 07 pm

Delete messages but UI did not update.

I tried to delete some message locally by method:

- (void)deleteMessagesLocally:(NSArray *)messages forDialogID:(NSString *)dialogID;

delegate method was called:

- (void)chatService:(QMChatService*)chatService didDeleteMessagesFromMemoryStorage:(NSArray QB_GENERIC(QBChatMessage*)*)messages forDialogID:(NSString*)dialogID {
    [self.chatSectionManager deleteMessages:messages];
}

but UI did not update.
Please check.

File not found issue

While doing manual installation i face bolts file not found issue attached screenshot.
screen shot 2016-02-11 at 5 04 59 pm

canot install QMServices

hi
I'm trying to integrate QuickBlox with my project but when I'm trying to Installing QMServices I get the next result:

hodayas-iMac:TryChat1 hodayaohana$ pod install
Updating local specs repositories

CocoaPods 1.0.0.beta.3 is available.
To update use: gem install cocoapods --pre
[!] This is a test version we'd love you to try.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Downloading dependencies
Installing Bolts (1.5.0)
Installing QMServices (0.3.6)

[!] Error installing QMServices
[!] /usr/bin/git clone https://github.com/QuickBlox/q-municate-services-ios.git /var/folders/31/gsb7b0615ps_1ds0ck44k3c40000gn/T/d20160216-22878-sgwomg --single-branch --depth 1 --branch 0.3.6

Cloning into '/var/folders/31/gsb7b0615ps_1ds0ck44k3c40000gn/T/d20160216-22878-sgwomg'...
Note: checking out 'a9db8f8f861153729936dac692c2fc71174ae50e'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b

Downloading Frameworks/Bolts.framework/Versions/A/Bolts (940.64 KB)
Error downloading object: Frameworks/Bolts.framework/Versions/A/Bolts (238480d343f8e10def84cf56218ab6c54868dafc0e2c803ecdf989b1a2f2efb8)

Errors logged to /private/var/folders/31/gsb7b0615ps_1ds0ck44k3c40000gn/T/d20160216-22878-sgwomg/.git/lfs/objects/logs/20160216T140807.145508476.log
Use git lfs logs last to view the log.
error: external filter git-lfs smudge %f failed 2
error: external filter git-lfs smudge %f failed
fatal: Frameworks/Bolts.framework/Versions/A/Bolts: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

How to download a file not image from attachment message?

I tried to upload some video file and audio file through attachment service but I can not find any function to download them except this method:

  • (void)getImageForAttachmentMessage:(QBChatMessage *)attachmentMessage completion:(void(^)(NSError *error, UIImage *image))completion {}

Please let me know how.

[Question] QMChatService fetch messages issue

Hi Quickblox team,

I'm facing problem when I try fetch message from GroupDialog.

    // Retrieving message from Quickblox REST history and cache.
    [[ServicesManager instance].chatService messagesWithChatDialogID:self.dialog.ID completion:^(QBResponse* response, NSArray* messages) {
        if (response.success) {
            if (showingProgress && !self.isSendingAttachment) {
                [SVProgressHUD dismiss];
            }
        } else {
            [SVProgressHUD showErrorWithStatus:@"Can not refresh messages"];
            NSLog(@"can not refresh messages: %@", response.error.error);
        }
    }];

Could you guys let me know my mistake.
Thank you in advance.

screen shot 2015-11-27 at 6 19 08 pm

Can not receive messages after delete dialog from memory storage

I delete dialog from memory storage by these methods:

 [[QMApi instance].chatService.dialogsMemoryStorage deleteChatDialogWithID:chatDialog.ID];
  [[QMApi instance].chatService.messagesMemoryStorage deleteMessagesWithDialogID:chatDialog.ID];

After that, I can not receive any message in this dialog anymore. Please check!

Dosen't recognize the filles of QuickBlox

Hi I am trying to add quickblox to my project
I add it with coocapods but when I'm trying to use the classes of quickBlox it dosnt recognize the class:
Use of undeclared type 'QBChatDialog'
mu podfile lookes like this: pod 'SVProgressHUD'
pod 'TWMessageBarManager', '~> 1.7.2'

pod 'QMServicesDevelopment', :git => 'https://github.com/QuickBlox/q-municate-services-ios.git', :branch => 'development'

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

canot install QMServices

I have tried to clone it again and I'm still get the same error:

hodayas-iMac:TryChat1 hodayaohana$ pod install
Updating local specs repositories

CocoaPods 1.0.0.beta.3 is available.
To update use: gem install cocoapods --pre
[!] This is a test version we'd love you to try.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Downloading dependencies
Installing Bolts (1.5.0)
Installing QMServices (0.3.6)

[!] Error installing QMServices
[!] /usr/bin/git clone https://github.com/QuickBlox/q-municate-services-ios.git /var/folders/31/gsb7b0615ps_1ds0ck44k3c40000gn/T/d20160217-31555-oga6gt --single-branch --depth 1 --branch 0.3.6

Cloning into '/var/folders/31/gsb7b0615ps_1ds0ck44k3c40000gn/T/d20160217-31555-oga6gt'...
Note: checking out 'a9db8f8f861153729936dac692c2fc71174ae50e'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b

git-lfs smudge 'Frameworks/Bolts.framework/Versions/A/Bolts': git-lfs: command not found
error: external filter git-lfs smudge %f failed -1
error: external filter git-lfs smudge %f failed
fatal: Frameworks/Bolts.framework/Versions/A/Bolts: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

hodayas-iMac:TryChat1 hodayaohana$ git lfs install --skip-smudge
git: 'lfs' is not a git command. See 'git --help'.

Did you mean this?
log

'parse issue:expected a type'

xqwad

I am new to Quickblox,I need to integrate with my Application,I have an issue with QMServiceDeployment.
Steps Followed:
i)Creating a Xcode Project
ii)Created a Cocoapods
pod 'QMServices'
iii)After successfully created the pods and opened my xcode workspace,It shows me 'parse issue:expected a type'
Can you please give me an idea/redirect me to solve my issue.

Thanks,
Shangari c.

!] The 'Pods-CSocial' target has transitive dependencies that include static binaries: (/Users/Desktop/Prototype/gh/Pods/QuickBlox/Quickblox.framework)

Hi ,
In my swift project
Im installing QMServices and QMChatViewController using following commands in pod file pod 'QMServices', '> 0.3'
pod 'QMChatViewController', '
> 0.3'
but i get the following error
!] The 'Pods' target has transitive dependencies that include static binaries: (/Users//Desktop/Prototype/kdsj/Pods/QuickBlox/Quickblox.framework)

Alternatively i used git link to for the above but dependencies are not getting installed even if i install if the branch is master

Need help kindly give suggestions
Note:I dont face the problem if i integrate the same in objective c project

Swift support

Pod install fails with message: The 'Pods' target has transitive dependencies that include static binaries

Update Bolts to 1.5.0

I'm trying to integrate QuickBlox with my project but when using version 0.3.3, it conflict with Facebook SDK because Facebook using Bolts 1.5.0.
Please update Bolts framework to 1.5.0

add pod 'QMServices'

Hi,

am trying to add pod 'QMServices' to my podfile in to a project that add Quickblox framework and I deleted it but when I add pod 'QMServices' it gives me a error

linker command failed with exit code 1

I am using xcode 7.2 with,
QuickBlox 2.6.2
QMServices 0.3.4
QMChatViewController 0.3.3
Quickblox-WebRTC 2.1.1 libraries

and error is following
ld: library not found for -lQMChatViewController
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is it possible to cache image attachment before upload it?

I would like to achieve a situation when user upload his image without showing him any status(In other words I would like to store the image as soon as user send it without waiting for confirmation) .(so all the work is done in the background thread).In your case :

 - (void)uploadAndSendAttachmentMessage:(QBChatMessage *)message toDialog:(QBChatDialog *)dialog withChatService:(QMChatService *)chatService withAttachedImage:(UIImage *)image completion:(QBChatCompletionBlock)completion { 
   [self changeMessageAttachmentStatus:QMMessageAttachmentStatusLoading forMessage:message];

    NSData *imageData = UIImagePNGRepresentation(image);

    [QBRequest TUploadFile:imageData fileName:@"attachment" contentType:@"image/png" isPublic:NO successBlock:^(QBResponse *response, QBCBlob *blob) {

        QBChatAttachment *attachment = [QBChatAttachment new];
        attachment.type = @"image";
        attachment.ID = [@(blob.ID) stringValue];
        attachment.url = [blob privateUrl];

        message.attachments = @[attachment];
        message.text = @"Attachment image";

        [self saveImageData:imageData chatAttachment:attachment error:nil];
        [self.attachmentsStorage setObject:image forKey:attachment.ID];

        [self changeMessageAttachmentStatus:QMMessageAttachmentStatusLoaded forMessage:message];

        [chatService sendMessage:message type:QMMessageTypeText toDialog:dialog saveToHistory:YES saveToStorage:YES completion:completion];

    } statusBlock:^(QBRequest *request, QBRequestStatus *status) {

    } errorBlock:^(QBResponse *response) {

        [self changeMessageAttachmentStatus:QMMessageAttachmentStatusNotLoaded forMessage:message];

        if (completion) completion(response.error.error);
    }];
}

So you cache it after you get a response (So for instance if we look at wats up the user can see the image right away).
Another thing that it can be nice to show a user an error near his image which will indicate on error uploading...
currently if the Image wasn't uploaded I need to delete it (but unfortunately I cannot find a way to do it with 0.3.3 version ).
The only option that i found is :
- (void)deleteMessages:(NSArray *)messages inContext:(NSManagedObjectContext *)context ;
Which I am not sure how to use...

Appreciate your assistance.

Can you provide a demo using QMServices at sub-module?

Currently, QMServices only allow upload/download image for attachment message.
I want to upload/download some type of file that is not image, so I write new functions. I had tried integrating QMServices via sub-module follow your guide but not success.

Can you provide an example for this guide, please?

QB Enterprise Licencsing

We are using QB Enterprise Medium Instance. Just wondering if we can use this library without sharing our code. In other words, Q-munity license don't apply to us, correct?

Thanks.

Adding Production Certificate.

When I try to add a production certificate in the DashBoard I receive the following error.(I alredy have a development profile which works fine).

Certificate errors:
2016-02-10 18:10:41 UTC: Connection reset by APNS: OpenSSL::SSL::SSLError, SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A

Can you please assist me with that?(Can you please also clarify how you distinguish between the production and the development to trigger the correct certificate. Should I add something to my code. )

Not able to get QMChatCacheModel.bundle, QMContactListCacheModel.bundle..

Hi

I have followed your steps to produce "QMContactListCacheModel.bundle", "QMUsersCacheModel.bundle" and "QMChatCacheModel.bundle". but still color is in red. so can you please help me to sort out this issue. it is most preferable if you provide direct link to download that bundles.

Thanks
Jatin Patel

QBChatMessage "nick" property not received.

When sending message, the nick name has been send. But when you receive message nick name is null.

#Posting the code:

### SENDING:

    QBChatMessage *message = [QBChatMessage message];
    message.dateSent = [NSDate date];
    message.text = text;
    message.senderID = senderId;
    message.senderNick = self.senderDisplayName;

*Debugging: *

 ID: 56e40e41d951e6cb1a0041a8            
 senderID: 10739420            
 recipientID: 0            
 dateSent: 2016-03-12 12:40:33 +0000            
 text: Hiii            
 customParameters: {
    "save_to_history" = 1;
}            
 attachments: (
    "
 type: (null) 
 url: (null) 
 ID: (null)"
)            
 delayed: 0            
 senderNick: dms_d          
 dialogID: (null)            
 read: 0            
 readIDs: (null)            
 deliveredIDs: (null)            
 markable: 0            
 createdAt: (null)            
 updatedAt: (null)

###RECEIVING:
*Debugging: *

ID: 56e40ee88689851c250041ab            
 senderID: 10743654            
 recipientID: 10739420            
 dateSent: 2016-03-12 12:43:21 +0000            
 text: Hii            
 customParameters: {
    "date_sent" = 1457786601;
    "dialog_id" = 56e2d69ca0eb47793e00002c;
    "message_id" = 56e40ee88689851c250041ab;
    "save_to_history" = 1;
}            
 attachments: (
    "
 type: (null) 
 url: (null) 
 ID: (null)"
)            
 delayed: 0            
 senderNick: (null)            
 dialogID: 56e2d69ca0eb47793e00002c            
 read: 1            
 readIDs: (
    10743654
)            
 deliveredIDs: (
    10743654
)            
 markable: 0            
 createdAt: (null)            
 updatedAt: (null)

For the moment the only solution what I found is to send nick name in customParameters.

'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: dialogID != nil'

 *** Assertion failure in -[QMChatService chatDidDeliverMessageWithID:dialogID:toUserID:],  Pods/QMServices/QMChatService/QMChatService/QMChatService.m:245
2015-12-02 16:36:15.289 Dogiz[13454:7103816] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: dialogID != nil'

Sometimes after sending message I get this Error ,I believe this delegate is called from your library with dialog == nil and that what cause a crash.(message ID and user are not null)
(I noticed that it happens after a reply)
Currently I do the following :

//in QMMessagesMemoryStorage.h

- (QBChatMessage *)findMessageByID:(NSString *)messageID{
    NSArray *dialogsIDs = [self.datasources allKeys];
    for (NSString *dialogId in dialogsIDs) {
        NSArray* messages = [self messagesWithDialogID:dialogId];
        for (QBChatMessage *msgInMemory in messages) {
            if ([msgInMemory.ID isEqualToString:messageID])
                return msgInMemory;
        }
    }
    return nil;
}

When the delegate is called I look for that message in the history and i continue if I find the dialog ,in case I don't find the correct dialog I quit the delegate(which also sometimes happens).
Can you please suggest what can be done?

Remove user from group issue.

I tried the remove user function.

  1. A create group with B, C, D.
  2. A remove B.
  3. A add B into group.
    => B can not receive message A added B.
  4. A, C, D type some messages in group
    => B can not receive any messages until go to other screen and comeback.

'NSInvalidArgumentException', reason: ' -[NSURL initFileURLWithPath:]: nil string parameter'

Hi,

I am receiving the following error while setting up the QMUsersCache Service.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:

0   CoreFoundation                      0x0000000105430f45 __exceptionPreprocess + 165`
1   libobjc.A.dylib                     0x000000010801fdeb objc_exception_throw + 48
2   CoreFoundation                      0x0000000105430e7d +[NSException raise:format:] + 205
3   Foundation                          0x0000000107bc7a67 -[NSURL(NSURL) initFileURLWithPath:] + 131
4   Foundation                          0x0000000107bc79cf +[NSURL(NSURL) fileURLWithPath:] + 45
5   Super                               0x0000000103441cee +[NSManagedObjectModel(QMCDRecord) QM_newModelNamed:inBundleNamed:] + 270
6   Super                               0x000000010342349e +[QMUsersCache setupDBWithStoreNamed:] + 94
7   Super                               0x000000010343447e -[QMServicesManager init] + 494

dosent recognize fiels of quickBlox framework

I have added QuickBlox framework to my project but when I'm trying to use the classes of the framework it gives me the next message:
Use of undeclared type 'QBChatDialog'

I added quickBlox with pods, this is my podfile:

target 'chat2' do

pod 'SVProgressHUD'
pod 'TWMessageBarManager', '~> 1.7.2'

pod 'QMServicesDevelopment', :git => 'https://github.com/QuickBlox/q-municate-services-ios.git', :branch => 'development'

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

pod 'QuickBlox'

pod 'QMServices'
pod 'QMChatViewController'
end

and my |Header file lookes like this:
@import UIKit;
@import Foundation;
@import SystemConfiguration;
@import MobileCoreServices;
@import Quickblox;

import <QMServices.h>

import <SVProgressHUD.h>

import "QMChatViewController.h"

import "QMChatContactRequestCell.h"

import "QMChatNotificationCell.h"

import "QMChatIncomingCell.h"

import "QMChatOutgoingCell.h"

import "QMCollectionViewFlowLayoutInvalidationContext.h"

import "TTTAttributedLabel.h"

import "TWMessageBarManager.h"

import "_CDMessage.h"

import "UIImage+QM.h"

import "UIColor+QM.h"

import "UIImage+fixOrientation.h"

Can not merge QMService to my clone git.

I saw QMService had updated to version 0.3.6 and I want to merge your code with mine.
But I got an issue:

git-lfs smudge 'Frameworks/Quickblox.framework/Versions/A/Quickblox': git-lfs: command not found
error: external filter git-lfs smudge %f failed -1
error: external filter git-lfs smudge %f failed
fatal: Frameworks/Quickblox.framework/Versions/A/Quickblox: smudge filter lfs failed

Please help!

!] The 'Pods-CSocial' target has transitive dependencies that include static binaries: (/Users/gayathri_b/Desktop/CSocialPrototype/csocial/Pods/QuickBlox/Quickblox.framework)

Hi ,
In my swift project
Im installing QMServices and QMChatViewController using following commands in pod file pod 'QMServices', '> 0.3'
pod 'QMChatViewController', '
> 0.3'
but i get the following error
!] The 'Pods' target has transitive dependencies that include static binaries: (/Users/gayathri_b/Desktop/Prototype/kdsj/Pods/QuickBlox/Quickblox.framework)

Alternatively i used git link to for the above but dependencies are not getting installed even if i install if the branch is master

Need help kindly give suggestions
Note:I dont face the problem if i integrate the same in objective c project

Sending message to Sender in group chat!!

In group chat when a user send a message the unread message count increases.So the message sent is also sent to the sender.More over the badge are not updated in the cache,the local data storage.

Can't compile project

  1. git clone https://github.com/QuickBlox/q-municate-services-ios.git
  2. Fix framework search paths in Quickblox.xcconfig to ../Frameworks
  3. Replace old Quickblox.framework in Frameworks with latest one.
  4. Add libextobjc library to External/libextobjc
  5. Add libextobjc to QMUsersService.xcodeproj, QMChatService.xcodeproj, add corresponding #imports of libextobjc files.
  6. Fix missing #import <Bolts/Bolts.h> in QMAuthService, QMChatService, and QMContactListService prefix headers.
    • Now each separate subproject of QMServices project compiles without errors.
  7. Build QMServices target.

Expected result:
It should build successfully after step 1.

Actual result:
Build fails on the line 10 of QMServices.h with error 'Quickblox/Quickblox.h' file not found, however it s there.

Can not play downloaded attachment video.

I tried to upload and download video but I can not play downloaded video.

Here is my code.

Upload:

- (void)uploadAndSendAttachmentMessage:(QBChatMessage*)message toDialog:(QBChatDialog*)dialog withChatService:(QMChatService*)chatService withAttachedVideo:(NSData*)videoData completion:(QBChatCompletionBlock)completion {
    [self changeMessageAttachmentStatus:QMMessageAttachmentStatusLoading forMessage:message];

    [QBRequest TUploadFile:videoData fileName:@"attachment video" contentType:@"video/mp4" isPublic:YES successBlock:^(QBResponse* response, QBCBlob* blob) {
        QBChatAttachment* attachment = [QBChatAttachment new];
        attachment.type = @"video";
        attachment.ID = blob.UID;
        attachment.url = [blob publicUrl];

        message.attachments = @[attachment];
        message.text = @"Attachment video";

        [self saveData:videoData chatAttachment:attachment error:nil];
        [self.attachmentsStorage setObject:videoData forKey:attachment.ID];

        [self changeMessageAttachmentStatus:QMMessageAttachmentStatusLoaded forMessage:message];

        [chatService sendMessage:message type:QMMessageTypeText toDialog:dialog saveToHistory:YES saveToStorage:YES completion:completion];
    } statusBlock:^(QBRequest* request, QBRequestStatus* status) {
        if ([self.delegate respondsToSelector:@selector(chatAttachmentService:didChangeUploadingProgress:forMessage:)]) {
            [self.delegate chatAttachmentService:self didChangeUploadingProgress:status.percentOfCompletion forMessage:message];
        }
    } errorBlock:^(QBResponse* response) {
        [self changeMessageAttachmentStatus:QMMessageAttachmentStatusNotLoaded forMessage:message];

        if (completion) {
            completion(response.error.error);
        }
    }];
}

Download:

- (void)getDataForAttachmentMessage:(QBChatMessage*)attachmentMessage completion:(void (^)(NSError* error, NSData* data))completion {
    if (attachmentMessage.attachmentStatus == QMMessageAttachmentStatusLoading || attachmentMessage.attachmentStatus == QMMessageAttachmentStatusError) {
        return;
    }

    QBChatAttachment* attachment = [attachmentMessage.attachments firstObject];

    // checking attachment in storage
    if ([self.attachmentsStorage objectForKey:attachment.ID] != nil) {
        if (completion) {
            completion(nil, [self.attachmentsStorage objectForKey:attachment.ID]);
        }
        return;
    }

    // checking attachment in cache
    NSString* path = attachmentPath(attachment);
    if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            NSError* error;
            NSData* data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedIfSafe error:&error];

            if (data != nil) {
                [self.attachmentsStorage setObject:data forKey:attachment.ID];
            }

            dispatch_async(dispatch_get_main_queue(), ^{
                if (completion) {
                    completion(error, data);
                }
            });
        });

        return;
    }

    // loading attachment from server
    [self changeMessageAttachmentStatus:QMMessageAttachmentStatusLoading forMessage:attachmentMessage];

    NSString* attachmentID    = attachment.ID;
    NSCharacterSet* notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];

    if ([attachmentID rangeOfCharacterFromSet:notDigits].location == NSNotFound) {
        [QBRequest downloadFileWithID:attachmentID.integerValue successBlock:^(QBResponse* response, NSData* fileData) {
            NSError* error;

            if (fileData != nil) {
                [self saveData:fileData chatAttachment:attachment error:&error];
                [self.attachmentsStorage setObject:fileData forKey:attachmentID];
            }

            [self changeMessageAttachmentStatus:QMMessageAttachmentStatusLoaded forMessage:attachmentMessage];

            if (completion) {
                completion(error, fileData);
            }
        } statusBlock:^(QBRequest* request, QBRequestStatus* status) {
            if ([self.delegate respondsToSelector:@selector(chatAttachmentService:didChangeLoadingProgress:forChatAttachment:)]) {
                [self.delegate chatAttachmentService:self didChangeLoadingProgress:status.percentOfCompletion forChatAttachment:attachment];
            }
        } errorBlock:^(QBResponse* response) {
            if (response.status == QBResponseStatusCodeNotFound) {
                [self changeMessageAttachmentStatus:QMMessageAttachmentStatusError forMessage:attachmentMessage];
            } else {
                [self changeMessageAttachmentStatus:QMMessageAttachmentStatusNotLoaded forMessage:attachmentMessage];
            }

            if (completion) {
                completion(response.error.error, nil);
            }
        }];
    } else {
        // attachment ID is UID
        [QBRequest downloadFileWithUID:attachment.ID successBlock:^(QBResponse* response, NSData* fileData) {
            NSError* error;

            if (fileData != nil) {
                [self saveData:fileData chatAttachment:attachment error:&error];
                [self.attachmentsStorage setObject:fileData forKey:attachmentID];
            }

            [self changeMessageAttachmentStatus:QMMessageAttachmentStatusLoaded forMessage:attachmentMessage];

            if (completion) {
                completion(error, fileData);
            }
        } statusBlock:^(QBRequest* request, QBRequestStatus* status) {
            if ([self.delegate respondsToSelector:@selector(chatAttachmentService:didChangeLoadingProgress:forChatAttachment:)]) {
                [self.delegate chatAttachmentService:self didChangeLoadingProgress:status.percentOfCompletion forChatAttachment:attachment];
            }
        } errorBlock:^(QBResponse* response) {
            if (response.status == QBResponseStatusCodeNotFound) {
                [self changeMessageAttachmentStatus:QMMessageAttachmentStatusError forMessage:attachmentMessage];
            } else {
                [self changeMessageAttachmentStatus:QMMessageAttachmentStatusNotLoaded forMessage:attachmentMessage];
            }

            if (completion) {
                completion(response.error.error, nil);
            }
        }];
    }
}

And play:

MPMoviePlayerViewController* movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
[self presentMoviePlayerViewControllerAnimated:movieController];
[movieController.moviePlayer play];

I copy download files to computer and still can not play.
It always presents video view controller then auto dismiss. Please help me.

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.