private void InitSendBird(Bundle extras)
        {
            if (extras != null)
            {
                String appId    = extras.GetString("appId");
                String uuid     = extras.GetString("uuid");
                String userName = extras.GetString("userName");

                mSyncContext = SynchronizationContext.Current;                 // required for ui update

                SendBirdNotificationHandler jnh = new SendBirdNotificationHandler();
                jnh.OnMessagingChannelUpdated += (sender, e) => {
                    mSendBirdMessagingChannelAdapter.Replace(e.MessagingChannel);
                };
                jnh.OnMentionUpdated += (sender, e) => {
                };

                SendBirdEventHandler ieh = new SendBirdEventHandler();
                ieh.OnConnect += (sender, e) => {
                };
                ieh.OnError   += (sender, e) => {
                    if (SendBird.CommonVar.IS_DEBUG)
                    {
                        Console.WriteLine("ieh Messaging OnError");
                        Console.WriteLine(e.ErrorCode);
                    }
                };
                ieh.OnMessagingEnded += (sender, e) => {
                };

                SendBirdSDK.Init(appId);
                SendBirdSDK.Login(uuid, userName);
                SendBirdSDK.RegisterNotificationHandler(jnh);
                SendBirdSDK.SetEventHandler(ieh);
            }
        }
        private void InitSendBird(Bundle extras)
        {
            mSendBirdInfo = extras;

            String appId    = extras.GetString("appId");
            String uuid     = extras.GetString("uuid");
            String userName = extras.GetString("userName");

            mSyncContext = SynchronizationContext.Current;             // required for api queries
            #region SendBirdEventHandler

            SendBirdNotificationHandler inh = new SendBirdNotificationHandler();
            inh.OnMessagingChannelUpdated += (sender, e) => {
                if (mMessagingChannel != null && mMessagingChannel.GetId() == e.MessagingChannel.GetId())
                {
                    mSyncContext.Post(delegate {
                        UpdateMessagingChannel(e.MessagingChannel);
                    }, null);
                }
            };
            inh.OnMentionUpdated += (sender, e) => {
            };

            SendBirdEventHandler ieh = new SendBirdEventHandler();
            ieh.OnConnect += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnConnect");
                }
            };
            ieh.OnError += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnError");
                    Console.WriteLine(e.ErrorCode);
                }
            };
            ieh.OnChannelLeft     += (sender, e) => {
            };
            ieh.OnMessageReceived += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnMessageReceived");
                }
                Console.WriteLine("CallMarkAsRead");
                SendBirdSDK.MarkAsRead();
                mSyncContext.Post(delegate {
                    mSendBirdMessagingAdapter.AddMessageModel(e.Message);
                }, null);
            };
            ieh.OnBroadcastMessageReceived += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnBroadcastMessageReceived");
                }
                mSyncContext.Post(delegate {
                    mSendBirdMessagingAdapter.AddMessageModel(e.Message);
                }, null);
            };
            ieh.OnSystemMessageReceived += (sender, e) => {
                var systemMessage = (SystemMessage)e.Message;
                switch (systemMessage.category)
                {
                case SystemMessage.CATEGORY_TOO_MANY_MESSAGES:
                    systemMessage.SetMessage("Too many messages. Please try later.");
                    break;

                case SystemMessage.CATEGORY_MESSAGING_USER_BLOCKED:
                    systemMessage.SetMessage("Blocked.");
                    break;

                case SystemMessage.CATEGORY_MESSAGING_USER_DEACTIVATED:
                    systemMessage.SetMessage("Deactivated.");
                    break;
                }

                mSendBirdMessagingAdapter.AddMessageModel(systemMessage);
            };
            ieh.OnFileReceived += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnFileReceived");
                }
            };
            ieh.OnReadReceived += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnReadReceived");
                }
                mSyncContext.Post(delegate {
                    mSendBirdMessagingAdapter.SetReadStatus(e.ReadStatus.GetUserId(), e.ReadStatus.timestamp);
                }, null);
            };
            ieh.OnTypeStartReceived += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnTypeStartReceived");
                }
                mSyncContext.Post(delegate {
                    mSendBirdMessagingAdapter.SetTypeStatus(e.TypeStatus.GetUserId(), SendBirdUtils.GetCurrentTimeMills());
                }, null);
            };
            ieh.OnTypeEndReceived += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnTypeEndReceived");
                }
                mSyncContext.Post(delegate {
                    mSendBirdMessagingAdapter.SetTypeStatus(e.TypeStatus.GetUserId(), 0);
                }, null);
            };
            ieh.OnAllDataReceived += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnAllDataReceived");
                }
                mSyncContext.Post(delegate {
                    mSendBirdMessagingAdapter.NotifyDataSetChanged();
                    mSendBirdMessagingFragment.mListView.SetSelection(mSendBirdMessagingAdapter.Count - 1);
                }, null);
            };
            ieh.OnMessageDelivery += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnMessageDelivery");
                }
                if (!e.Sent)
                {
                    mSendBirdMessagingFragment.mEtxtMessage.Text = e.Message;
                }
            };
            ieh.OnMessagingStarted += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnMessagingStarted");
                }
                mSendBirdMessagingAdapter.Clear();
                UpdateMessagingChannel(e.MessagingChannel);

                var channelUrl = e.MessagingChannel.GetUrl();

                MessageListQuery messageListQuery = SendBirdSDK.QueryMessageList(channelUrl);
                messageListQuery.OnResult += (sender_child, e_child) => {
                    // mSyncContext.Post for RunOnUIThread
                    mSyncContext.Post(delegate {
                        foreach (var messageModel in e_child.Messages)
                        {
                            mSendBirdMessagingAdapter.AddMessageModel(messageModel);
                        }

                        mSendBirdMessagingAdapter.NotifyDataSetChanged();
                        mSendBirdMessagingFragment.mListView.SetSelection(30);

                        SendBirdSDK.MarkAsRead(channelUrl);
                        SendBirdSDK.Join(channelUrl);
                        SendBirdSDK.Connect(mSendBirdMessagingAdapter.GetMaxMessageTimestamp());
                    }, null);
                };
                messageListQuery.Prev(long.MaxValue, 50);                  // Excute Query
            };
            ieh.OnMessagingUpdated += (sender, e) => {
                if (SendBird.CommonVar.IS_DEBUG)
                {
                    Console.WriteLine("ieh Messaging OnMessagingUpdated");
                }
                mSyncContext.Post(delegate {
                    UpdateMessagingChannel(e.MessagingChannel);
                }, null);
            };

            #endregion

            SendBirdSDK.Init(appId);
            SendBirdSDK.Login(uuid, userName);
            SendBirdSDK.RegisterNotificationHandler(inh);
            SendBirdSDK.SetEventHandler(ieh);
        }