Skip to content

Instantly share code, notes, and snippets.

@adarshmishra
Last active August 29, 2017 06:09
Show Gist options
  • Save adarshmishra/0335d78878a2a55647cb84482d5ab92d to your computer and use it in GitHub Desktop.
Save adarshmishra/0335d78878a2a55647cb84482d5ab92d to your computer and use it in GitHub Desktop.
Applozic Chat
-(void)launchGroupOfTwoWithClientId:(NSString*)clientGroupId
withMetaData:(NSMutableDictionary*)metadata
andWithUser:(NSString *)userId
andFromViewController:(UIViewController *)viewController
{
ALChannelService * channelService = [[ALChannelService alloc] init];
ALChannel *alChannel = [channelService fetchChannelWithClientChannelKey:clientGroupId];
if (alChannel){
[self launchChatForUserWithDisplayName:nil withGroupId:alChannel.key
andwithDisplayName:nil andFromViewController:viewController];
}
else
{
[channelService getChannelInformation:nil orClientChannelKey:clientGroupId withCompletion:^(ALChannel *alChannel) {
if(alChannel.key){
[self launchChatForUserWithDisplayName:nil withGroupId:alChannel.key
andwithDisplayName:nil andFromViewController:viewController];
}else{
//Create new one channel and launch:;;
[channelService createChannel:clientGroupId orClientChannelKey:clientGroupId andMembersList:@[userId]
andImageLink:nil channelType:GROUP_OF_TWO
andMetaData:metadata withCompletion:^(ALChannel *alChannelInRespose, NSError *error) {
NSLog(@" group of two id %@", alChannelInRespose.key);
[self launchChatForUserWithDisplayName:nil withGroupId:alChannelInRespose.key
andwithDisplayName:nil andFromViewController:viewController];
}];
}
}];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment