2016-01-30 25 views
1

我正在嘗試使用預先指定的參與者創建ConversationViewController。當我創建對話並推送控制器時,參與者地址欄不顯示任何名稱。另外,如果現有對話已開始,則會引發錯誤。Layer-Atlas iOS ConversationViewController設置對話不起作用

如何使用指定參與者推送ConversationViewController?

下面是代碼和調試器輸出,以幫助您瞭解我在哪裏:

ConversationViewController *controller = [ConversationViewController conversationViewControllerWithLayerClient:SingletonCenter.layerClient]; 
NSError *error; 
LYRConversation *conversation = [SingletonCenter.layerClient newConversationWithParticipants:[NSSet setWithArray:@[User.objectId,self.requestForView.serviceProvider.objectId]] options:nil error:&error]; 
NSLog(@"conversation is: %@\nerror is: %@",conversation, [error localizedDescription]); 
controller.conversation = conversation; 
controller.displaysAddressBar = YES; 
[self.navigationController pushViewController:controller animated:YES]; 

談話:「LYRConversation:0x7faa724a7730標識符=層:///對話/ c8eeaf04-085b-4c11-a985- a23aeeeb5f3e databaseIdentifier = LYRDatabaseIdentifierNotDefined版本= LYRVersionNotDefined請將isDeleted = NO streamUUID =(空)的參與者= {( Y8Ak1U1Mbj, AdW9c2FYeN )} distinctByParticipants = YES」

談話是:(空) 錯誤是:具有鮮明的參與者列表的對話已經存在的參與者{( Y8Ak1U1Mbj, AdW9c2FYeN )}

+0

我認爲,你想用的標籤是「layerkit」而不是「層」 –

+0

你說得對 –

回答

0

當這些參與者的對話中已經存在的錯誤將被拋出。處理該問題的方法是從錯誤的用戶信息中提取對話ID。

這是直接從Layerkit的例子:

// Fetches all conversations between the authenticated user and the supplied participant 
// For more information about Querying, check out https://developer.layer.com/docs/integration/ios#querying 
if (!self.conversation) { 
    NSError *error; 
    // Trying creating a new distinct conversation between all 3 participants 
    self.conversation = [self.layerClient newConversationWithParticipants:[NSSet setWithArray:@[ LQSParticipantUserID, LQSParticipant2UserID ]] options:nil error:&error]; 
    if (!self.conversation) { 
     // If a conversation already exists, use that one 
     if (error.code == LYRErrorDistinctConversationExists) { 
      self.conversation = error.userInfo[LYRExistingDistinctConversationKey]; 
      NSLog(@"Conversation already exists between participants. Using existing"); 
     } 
    } 
}