Commit 13ee1d17 authored by Dominic Vedericho's avatar Dominic Vedericho
Browse files

bug fixing group chat

parent 2aa9b243
......@@ -7,15 +7,15 @@
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
buildForArchiving = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ECEFF4DE87169A8335FFBC8B46312B9E"
BuildableName = "Pods_TapTalk.framework"
BuildableName = "Pods-TapTalk.framework"
BlueprintName = "Pods-TapTalk"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
......@@ -23,17 +23,14 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
......@@ -41,25 +38,17 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ECEFF4DE87169A8335FFBC8B46312B9E"
BuildableName = "Pods_TapTalk.framework"
BlueprintName = "Pods-TapTalk"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
......
......@@ -8,85 +8,61 @@
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>GoogleMaps.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>GooglePlacePicker.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>GooglePlaces.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>JSONModel.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>4</integer>
</dict>
<key>PodAsset.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>5</integer>
</dict>
<key>Pods-TapTalk.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>6</integer>
</dict>
<key>Realm.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>7</integer>
</dict>
<key>SDWebImage.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>8</integer>
</dict>
<key>SocketRocket.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>9</integer>
</dict>
<key>ZBarSDK.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>10</integer>
</dict>
<key>ZSWTappableLabel.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>11</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
......
......@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#
s.name = "TapTalk"
s.version = "1.0.2"
s.version = "1.0.3"
s.summary = "Powerful Chat Engine"
# This description is used to generate tags and improve search results.
......@@ -78,7 +78,7 @@ Pod::Spec.new do |s|
#
# s.source = { :path => '.' }
s.source = { :git => 'git@git.taptalk.io:ios/taptalk-ios.git', :tag => '1.0.2' }
s.source = { :git => 'git@git.taptalk.io:ios/taptalk-ios.git', :tag => '1.0.3' }
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
......
No preview for this file type
......@@ -132,6 +132,7 @@
+ (CGFloat)safeAreaBottomPadding;
+ (CGFloat)safeAreaTopPadding;
+ (void)delayCallback:(void(^)(void))callback forTotalSeconds:(double)delayInSeconds;
+ (void)performBlock:(void (^)())block afterDelay:(NSTimeInterval)delay;
#pragma mark - TapTalk
+ (NSBundle *)currentBundle;
......
......@@ -933,6 +933,17 @@ static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWi
});
}
+ (void)performBlock:(void (^)())block
{
block();
}
+ (void)performBlock:(void (^)())block afterDelay:(NSTimeInterval)delay
{
void (^block_)() = [block copy]; // autorelease this if you're not using ARC
[self performSelector:@selector(performBlock:) withObject:block_ afterDelay:delay];
}
#pragma mark - TapTalk
+ (NSBundle *)currentBundle {
NSBundle *resourceBundle = [PodAsset bundleForPod:@"TapTalk"];
......
......@@ -17,6 +17,7 @@ typedef NS_ENUM(NSInteger, TAPAPIManagerType) {
TAPAPIManagerTypeGetMessageRoomListAfter,
TAPAPIManagerTypeGetMessageRoomListBefore,
TAPAPIManagerTypeGetPendingNewAndUpdatedMessages,
TAPAPIManagerTypeLogout,
TAPAPIManagerTypeGetContactList,
TAPAPIManagerTypeAddContact,
TAPAPIManagerTypeRemoveContact,
......
......@@ -59,10 +59,10 @@ static NSString * const kAPIVersionString = @"v1";
#pragma mark - Custom Method
- (NSString *)urlForType:(TAPAPIManagerType)type {
if (type == TAPAPIManagerTypeGetAuthTicket) {
NSString *apiPath = @"server/auth_ticket/request";
return [NSString stringWithFormat:@"%@/%@/%@", self.APIBaseURL, kAPIVersionString, apiPath];
}
else if (type == TAPAPIManagerTypeGetAccessToken) {
NSString *apiPath = @"auth/access_token/request";
......@@ -93,6 +93,10 @@ static NSString * const kAPIVersionString = @"v1";
NSString *apiPath = @"chat/message/new_and_updated";
return [NSString stringWithFormat:@"%@/%@/%@", self.APIBaseURL, kAPIVersionString, apiPath];
}
else if (type == TAPAPIManagerTypeLogout) {
NSString *apiPath = @"client/logout";
return [NSString stringWithFormat:@"%@/%@/%@", self.APIBaseURL, kAPIVersionString, apiPath];
}
else if (type == TAPAPIManagerTypeGetContactList) {
NSString *apiPath = @"client/contact/list";
return [NSString stringWithFormat:@"%@/%@/%@", self.APIBaseURL, kAPIVersionString, apiPath];
......
......@@ -29,7 +29,7 @@ typedef NS_ENUM(NSInteger, TAPChatManagerQuoteActionType) {
@optional
- (void)chatManagerDidSendNewMessage:(TAPMessageModel *)message;
- (void)chatManagerDidAddUnreadMessageIdentifier:(TAPMessageModel *)message indexPosition:(NSInteger)index;
//- (void)chatManagerDidAddUnreadMessageIdentifier:(TAPMessageModel *)message indexPosition:(NSInteger)index;
- (void)chatManagerDidReceiveNewMessageInActiveRoom:(TAPMessageModel *)message;
- (void)chatManagerDidReceiveNewMessageOnOtherRoom:(TAPMessageModel *)message;
- (void)chatManagerDidReceiveUpdateMessageInActiveRoom:(TAPMessageModel *)message;
......@@ -81,7 +81,7 @@ typedef NS_ENUM(NSInteger, TAPChatManagerQuoteActionType) {
- (void)sendLocationMessage:(CGFloat)latitude longitude:(CGFloat)longitude address:(NSString *)address room:(TAPRoomModel *)room;
- (void)sentFileMessage:(TAPDataFileModel *)dataFile filePath:(NSString *)filePath;
- (void)sentFileMessage:(TAPDataFileModel *)dataFile filePath:(NSString *)filePath room:(TAPRoomModel *)room;
- (void)generateUnreadMessageIdentifierWithRoom:(TAPRoomModel *)room created:(NSNumber *)created indexPosition:(NSInteger)index;
- (TAPMessageModel *)generateUnreadMessageIdentifierWithRoom:(TAPRoomModel *)room created:(NSNumber *)created indexPosition:(NSInteger)index;
- (void)saveMessageToDraftWithMessage:(NSString *)message roomID:(NSString *)roomID;
- (NSString *)getMessageFromDraftWithRoomID:(NSString *)roomID;
......
......@@ -854,13 +854,15 @@
[[TAPFileUploadManager sharedManager] sendFileWithData:message];
}
- (void)generateUnreadMessageIdentifierWithRoom:(TAPRoomModel *)room created:(NSNumber *)created indexPosition:(NSInteger)index {
- (TAPMessageModel *)generateUnreadMessageIdentifierWithRoom:(TAPRoomModel *)room created:(NSNumber *)created indexPosition:(NSInteger)index {
TAPMessageModel *message = [TAPMessageModel createMessageWithUser:[TAPChatManager sharedManager].activeUser created:created room:room body:@"" type:TAPChatMessageTypeUnreadMessageIdentifier];
for (id delegate in self.delegatesArray) {
if ([delegate respondsToSelector:@selector(chatManagerDidAddUnreadMessageIdentifier:indexPosition:)]) {
[delegate chatManagerDidAddUnreadMessageIdentifier:message indexPosition:index];
}
}
return message;
// for (id delegate in self.delegatesArray) {
// if ([delegate respondsToSelector:@selector(chatManagerDidAddUnreadMessageIdentifier:indexPosition:)]) {
// [delegate chatManagerDidAddUnreadMessageIdentifier:message indexPosition:index];
// }
// }
}
- (void)setActiveUser:(TAPUserModel *)activeUser {
......@@ -977,7 +979,7 @@
decryptedMessage.isSending = NO;
#ifdef DEBUG
NSLog(@"Receive Message: %@", decryptedMessage.body);
NSLog(@"Receive Message (event: %@, localID: %@): %@", eventName, decryptedMessage.localID, decryptedMessage.body);
#endif
if ([eventName isEqualToString:kTAPEventNewMessage]) {
......
......@@ -151,6 +151,8 @@
failure:(void (^)(NSError *error))failure;
//API Call
+ (void)callAPILogoutWithSuccess:(void (^)(void))success
failure:(void (^)(NSError *error))failure;
+ (void)callAPIGetAuthTicketWithUser:(TAPUserModel *)user
success:(void (^)(NSString *authTicket))success
failure:(void (^)(NSError *error))failure; //DV Temp
......
......@@ -2168,8 +2168,69 @@
}
#pragma mark - API Call
//DV Temp
//DV Note - Temporary force call API to server to get Auth Ticket
+ (void)callAPILogoutWithSuccess:(void (^)(void))success
failure:(void (^)(NSError *error))failure {
NSString *requestURL = [[TAPAPIManager sharedManager] urlForType:TAPAPIManagerTypeLogout];
NSMutableDictionary *parameterDictionary = [NSMutableDictionary dictionary];
[[TAPNetworkManager sharedManager] post:requestURL parameters:parameterDictionary progress:^(NSProgress *uploadProgress) {
} success:^(NSURLSessionDataTask *dataTask, NSDictionary *responseObject) {
if (![self isResponseSuccess:responseObject]) {
NSDictionary *errorDictionary = [responseObject objectForKey:@"error"];
NSString *errorMessage = [errorDictionary objectForKey:@"message"];
errorMessage = [TAPUtil nullToEmptyString:errorMessage];
NSString *errorStatusCodeString = [responseObject objectForKey:@"status"];
errorStatusCodeString = [TAPUtil nullToEmptyString:errorStatusCodeString];
NSInteger errorStatusCode = [errorStatusCodeString integerValue];
if (errorStatusCode == 401) {
//Call refresh token
[[TAPDataManager sharedManager] callAPIRefreshAccessTokenSuccess:^{
[TAPDataManager callAPILogoutWithSuccess:success failure:failure];
} failure:^(NSError *error) {
failure(error);
}];
return;
}
NSInteger errorCode = [[responseObject valueForKeyPath:@"error.code"] integerValue];
if (errorMessage == nil || [errorMessage isEqualToString:@""]) {
errorCode = 999;
}
NSError *error = [NSError errorWithDomain:errorMessage code:errorCode userInfo:@{@"message": errorMessage}];
failure(error);
return;
}
if ([self isDataEmpty:responseObject]) {
success();
return;
}
success();
} failure:^(NSURLSessionDataTask *dataTask, NSError *error) {
[TAPDataManager logErrorStringFromError:error];
#ifdef DEBUG
NSString *errorDomain = error.domain;
NSString *newDomain = [NSString stringWithFormat:@"%@ ~ %@", requestURL, errorDomain];
NSError *newError = [NSError errorWithDomain:newDomain code:error.code userInfo:error.userInfo];
failure(newError);
#else
NSError *localizedError = [NSError errorWithDomain:NSLocalizedString(@"We are experiencing problem to connect to our server, please try again later...", @"") code:999 userInfo:@{@"message": NSLocalizedString(@"Failed to connect to our server, please try again later...", @"")}];
failure(localizedError);
#endif
}];
}
+ (void)callAPIGetAuthTicketWithUser:(TAPUserModel *)user
success:(void (^)(NSString *authTicket))success
......@@ -4494,7 +4555,7 @@
user.isContact = YES;
//Add User to Contact Manager
[[TAPContactManager sharedManager] addContactWithUserModel:user saveToDatabase:NO];
[[TAPContactManager sharedManager] addContactWithUserModel:user saveToDatabase:YES];
[userResultArray addObject:user];
}
......
......@@ -25,7 +25,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (TAPNotificationManager *)sharedManager;
- (void)setPushToken:(NSString *)pushToken;
- (NSString *)pushToken;
- (void)handlePushNotificationWithUserInfo:(NSDictionary *)userInfo;
- (void)handleIncomingMessage:(TAPMessageModel *)message shouldShowNotification:(BOOL)shouldShowNotification;
- (void)handleTappedNotificationWithUserInfo:(NSDictionary *)userInfo;
......
......@@ -69,12 +69,6 @@
#pragma mark - Custom Method
- (void)setPushToken:(NSString *)pushToken {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:TAP_PREFS_PUSH_TOKEN];
[[NSUserDefaults standardUserDefaults] synchronize];
[[NSUserDefaults standardUserDefaults] setSecureObject:pushToken forKey:TAP_PREFS_PUSH_TOKEN];
[[NSUserDefaults standardUserDefaults] synchronize];
NSString *accessToken = [TAPDataManager getAccessToken];
if (![accessToken isEqualToString:@""] && accessToken != nil) {
BOOL isDebug = NO;
......@@ -85,20 +79,13 @@
#endif
[TAPDataManager callAPIUpdatePushNotificationWithToken:pushToken isDebug:isDebug success:^{
[[NSUserDefaults standardUserDefaults] removeObjectForKey:TAP_PREFS_PUSH_TOKEN];
[[NSUserDefaults standardUserDefaults] synchronize];
} failure:^(NSError *error) {
}];
}
}
- (NSString *)pushToken {
NSString *pushToken = [[NSUserDefaults standardUserDefaults] secureObjectForKey:TAP_PREFS_PUSH_TOKEN valid:nil];
pushToken = [TAPUtil nullToEmptyString:pushToken];
return pushToken;
}
- (void)handlePushNotificationWithUserInfo:(NSDictionary *)userInfo {
#ifdef DEBUG
NSLog(@"Did receive notification: %@", [userInfo description]);
......
......@@ -110,7 +110,8 @@ typedef NS_ENUM(NSInteger, TAPComponentColor) {
TAPComponentColorIconChatComposerShowKeyboard, //Chat Room
TAPComponentColorIconChatComposerSendBackground, //Chat Room
TAPComponentColorIconChatComposerSendBackgroundInactive, //Chat Room
TAPComponentColorIconDeletedLeftMessageBubble, //Chat Room
TAPComponentColorIconDeletedRightMessageBubble, //Chat Room
};
typedef NS_ENUM(NSInteger, TAPTextColor) {
......
......@@ -2195,15 +2195,18 @@
return color;
break;
}
// TAPComponentColorIconChatComposerSend, //Chat Room
// TAPComponentColorIconChatComposerSendInactive, //Chat Room
// TAPComponentColorIconChatComposerBurgerMenu, //Chat Room
// TAPComponentColorIconChatComposerSendBackground, //Chat Room
// TAPComponentColorIconChatComposerSendBackgroundInactive, //Chat Room
case TAPComponentColorIconDeletedLeftMessageBubble:
{
UIColor *color = [[TAPStyleManager sharedManager] getDefaultColorForType:TAPDefaultColorIconGray];
return color;
break;
}
case TAPComponentColorIconDeletedRightMessageBubble:
{
UIColor *color = [[TAPStyleManager sharedManager] getDefaultColorForType:TAPDefaultColorIconWhite];
return color;
break;
}
default: {
//Set default color to black to prevent crash
UIColor *color = [TAPUtil getColor:@"9B9B9B"];
......
......@@ -31,7 +31,7 @@ typedef NS_ENUM(NSInteger, TAPChatMessageType) {
TAPChatMessageTypeOrderCard = 3001,
TAPChatMessageTypeSystemMessage = 9001,
TAPChatMessageTypeUnreadMessageIdentifier = 9003,
TAPChatMessageTypeUnreadMessageIdentifier = 9002,
};
......
......@@ -71,6 +71,9 @@ typedef NS_ENUM(NSInteger, TapTalkEnvironment) {
//Badge
- (void)tapTalkSetBadgeWithNumberOfUnreadRooms:(NSInteger)numberOfUnreadRooms;
//Notification
- (void)tapTalkDidRequestRemoteNotification;
@end
@interface TapTalk : NSObject
......@@ -174,7 +177,8 @@ fromNavigationController:(UINavigationController *)navigationController
//Other
- (void)disconnect;
- (void)logoutAndClearAllData;
- (void)logoutAndClearAllDataWithSuccess:(void (^)(void))success
failure:(void (^)(NSError *error))failure;
- (void)clearAllData;
//TapTalk Internal Usage Method
......
......@@ -73,24 +73,10 @@
}
[TAPDataManager callAPIGetAccessTokenWithAuthTicket:authTicket success:^{
//Send Push Token to server
NSString *pushToken = [[TAPNotificationManager sharedManager] pushToken];
if (pushToken != nil) {
BOOL isDebug = NO;
#ifdef DEBUG
isDebug = YES;
#else
isDebug = NO;
#endif
[TAPDataManager callAPIUpdatePushNotificationWithToken:pushToken isDebug:isDebug success:^{
[[NSUserDefaults standardUserDefaults] removeObjectForKey:TAP_PREFS_PUSH_TOKEN];
[[NSUserDefaults standardUserDefaults] synchronize];
} failure:^(NSError *error) {
}];
//Check need to send push token to server
if ([[TapTalk sharedInstance].delegate respondsToSelector:@selector(tapTalkDidRequestRemoteNotification)]) {
[[TapTalk sharedInstance].delegate tapTalkDidRequestRemoteNotification];
}
[[TAPChatManager sharedManager] connect];
......@@ -228,6 +214,11 @@
if ([TAPChatManager sharedManager].activeUser != nil) {
//User active
[[TAPConnectionManager sharedManager] connect];
//Check is need to trigger get push token flow
if ([[TapTalk sharedInstance].delegate respondsToSelector:@selector(tapTalkDidRequestRemoteNotification)]) {
[[TapTalk sharedInstance].delegate tapTalkDidRequestRemoteNotification];
}
}
//Start trigger timer to save new message
......@@ -252,7 +243,9 @@
pushToken = [pushToken stringByReplacingOccurrencesOfString:@">" withString:@""];
pushToken = [pushToken stringByReplacingOccurrencesOfString:@" " withString:@""];
#ifdef DEBUG
NSLog(@"PUSH TOKEN: %@", pushToken);
#endif
[[TAPNotificationManager sharedManager] setPushToken:pushToken];
}
......@@ -781,13 +774,20 @@ fromNavigationController:(UINavigationController *)navigationController
[[TAPChatManager sharedManager] disconnect];
}
- (void)logoutAndClearAllData {
[[TapTalk sharedInstance] clearAllData];
[[TapTalk sharedInstance] disconnect];
TAPLoginViewController *loginViewController = [[TapTalk sharedInstance] loginViewController];
[loginViewController presentLoginViewControllerIfNeededFromViewController:[[TapTalk sharedInstance] roomListViewController] force:YES];
- (void)logoutAndClearAllDataWithSuccess:(void (^)(void))success
failure:(void (^)(NSError *error))failure {
[TAPDataManager callAPILogoutWithSuccess:^{
[[TapTalk sharedInstance] clearAllData];
[[TapTalk sharedInstance] disconnect];
success();
TAPLoginViewController *loginViewController = [[TapTalk sharedInstance] loginViewController];
[loginViewController presentLoginViewControllerIfNeededFromViewController:[[TapTalk sharedInstance] roomListViewController] force:YES];
} failure:^(NSError *error) {
failure(error);
}];
}
- (void)clearAllData {
......@@ -800,7 +800,6 @@ fromNavigationController:(UINavigationController *)navigationController
//Remove all preference
[[NSUserDefaults standardUserDefaults] removeObjectForKey:TAP_PREFS_ACTIVE_USER];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:TAP_PREFS_PUSH_TOKEN];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:TAP_PREFS_ACCESS_TOKEN];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:TAP_PREFS_REFRESH_TOKEN];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:TAP_PREFS_REFRESH_TOKEN_EXPIRED_TIME];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment