2016-11-24 4 views
2

最近、私はcurrentChannel.getMessages()を返すnullを返すときに、最近のversion twilio chat 0.11.1をサポートするようにアプリケーションを更新しました。 私は多分あなたはチャンネルを同期するのを忘れ、私はメッセージなしで利用可能Twilioチャットで現在のチャンネルのメッセージを呼び出すときにnullを取得するandroid

| WARNING | ChatUtils(native) | ListenerWrapper default onSuccess() not found 
| WARNING | Channel(native) | No messages available, maybe you forgot to synchronize the channel? 

答えて

1

のような警告を得た

 Channels channelsObject = basicClient.getIpMessagingClient 
     channelsObject.getChannel(channelId, new CallbackListener<Channel>() { 
        @Override 
        public void onSuccess(final Channel channel) { 
         currentChannel = channel; 
         setupRecyclerView(); 
        } 
       }); 
     private void setupRecyclerView() { 
       currentChannel.addListener(ChatFragment.this); 
       currentChannel.synchronize(new com.twilio.chat.CallbackListener<Channel>() { 
       @Override 
       public void onError(ErrorInfo errorInfo) { 
       Application.get().logErrorInfo("Channel sync failed", errorInfo); 
       } 

       @Override 
       public void onSuccess(Channel result) { 
       logger.d("Channel sync success for " + result.getFriendlyName()); 
      } 
     }); 
     Messages messagesObject = currentChannel.getMessages(); 

のようにやっていますか?

これはまさに起こっていることです。チャネルは、CallbackListener.onSuccess()コールバックを受信した場合にのみ同期されます。これは非同期に実行され、そのコールバックが起動する前にgetMessages()呼び出しが実行されます。

 currentChannel.synchronize(new com.twilio.chat.CallbackListener<Channel>() { 
      @Override 
      public void onError(ErrorInfo errorInfo) { 
      Application.get().logErrorInfo("Channel sync failed", errorInfo); 
      } 

      @Override 
      public void onSuccess(Channel result) { 
      logger.d("Channel sync success for " + result.getFriendlyName() + " now can get messages and members objects"); 
      Messages messagesObject = result.getMessages(); 
      // should be non-null now 
      } 
     }); 
+0

ありがとうございました。しかし、初めての同期には時間がかかっています(3〜4秒)。期待していますか? –

+0

これはSDKで最適化するものです - 空のチャンネルで3〜4秒かかるのですか? – Berkus

+0

はい。それはまた、空のチャンネルのために3-4秒かかる。 –

関連する問題