Как настроить AWSLexButtons в чате, используя JSQMessagesViewController?IOS - PullRequest
0 голосов
/ 05 февраля 2019

Я получаю ответ в этом методе

-(void)interactionKit:(AWSLexInteractionKit *)interactionKit
   switchModeInput:(AWSLexSwitchModeInput *)switchModeInput
  completionSource:(AWSTaskCompletionSource<AWSLexSwitchModeResponse *> *)completionSource{
NSLog(@"completioSource : %@",completionSource);

self.sessionAttributes = switchModeInput.sessionAttributes;

dispatch_async(dispatch_get_main_queue(), ^{
    JSQMessage *message = nil;

    if (switchModeInput.outputText != nil) {

        NSLog(@"session attribute : %@",switchModeInput.sessionAttributes);
        NSLog(@"session aws properties : %@", switchModeInput.aws_properties);



        message = [[JSQMessage alloc] initWithSenderId:SERVER_SENDER_ID
                                     senderDisplayName:@""
                                                  date:[[NSDate alloc]init]
                                                  text:switchModeInput.outputText];

      //  message = [[JSQMessage alloc]initWithSenderId:SERVER_SENDER_ID senderDisplayName:@"" date:[[NSDate alloc]init] media:switchModeInput.accessibilityElementDidLoseFocus];

        [self.messages addObject:message];
    }

    [self finishSendingMessageAnimated:YES];
});

// This can expand to take input from user.
AWSLexSwitchModeResponse *switchModeResponse = [AWSLexSwitchModeResponse new];
[switchModeResponse setInteractionMode:AWSLexInteractionModeText];
[switchModeResponse setSessionAttributes:switchModeInput.sessionAttributes];
[completionSource setResult:switchModeResponse];
}

и вывод:

msgData : (
    "<JSQMessage: senderId=client, senderDisplayName=Sender, date=2019-02-05 11:59:29 +0000, isMediaMessage=0, text=Book Appointment, media=(null)>",
    "<JSQMessage: senderId=server, senderDisplayName=, date=2019-02-05 11:59:32 +0000, isMediaMessage=0, text=Which city would you look to book an appointment in?<br> Choose from the list of cities below., media=(null)>"
)

Мне нужно прочитать полный JSON из AWSLex или Able, чтобы создать AWSLexButtons в чате.Любая помощь будет оценена.Заранее спасибо.

...