// ios用
function callNativeApp(iosKey, jsonData) {
  console.log("callNativeApp called");
  var result;
  try {
    var key = iosKey;
    var data = jsonData;
    var payload = { key: key, data: data };
    // payloadの形 {"type":"SJbridge","data":{"name":"abc","role":"dev"}}
    // resにObjective-cからのレスポンスが返る
    result = prompt(JSON.stringify(payload));
    console.log(result);
  } catch (err) {
    console.log("The native context does not exist yet");
  }
  return result;
}

CHAT_DB.getBeforeRoomType = function () {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    return callNativeApp(NATIVE_KEY_IOS.getBeforeRoomType, {});
  }
};

CHAT_DB.getRoomType = function () {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    return parseInt(callNativeApp(NATIVE_KEY_IOS.getRoomType, {}), 10);
  }
};

CHAT_DB.removeFavoriteUser = function (shopMemberId) {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    var result = callNativeApp(NATIVE_KEY_IOS.removeFavoriteUser, {
      shopMemberId: shopMemberId,
    });
    if (result == "true") {
      return true;
    } else {
      return false;
    }
  }
};

CHAT_DB.addFavoriteUser = function (shopMemberId) {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    var result = callNativeApp(NATIVE_KEY_IOS.addFavoriteUser, {
      shopMemberId: shopMemberId,
    });
    if (result == "true") {
      return true;
    } else {
      return false;
    }
  }
};

CHAT_DB.removeFavoriteGroup = function (groupId) {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    var result = callNativeApp(NATIVE_KEY_IOS.removeFavoriteGroup, {
      groupId: groupId,
    });
    if (result == "true") {
      return true;
    } else {
      return false;
    }
  }
};

CHAT_DB.addFavoriteGroup = function (groupId) {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    var result = callNativeApp(NATIVE_KEY_IOS.addFavoriteGroup, {
      groupId: groupId,
    });
    if (result == "true") {
      return true;
    } else {
      return false;
    }
  }
};

CHAT_DB.getCollaborationJoinFlg = function () {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    return callNativeApp(NATIVE_KEY_IOS.getCollaborationJoinFlg, {});
  }
};

CHAT_DB.getUserInfoList = function (shopMemberId) {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    return callNativeApp(NATIVE_KEY_IOS.getUserInfoList, {
      shopMemberId: shopMemberId,
    });
  }
};

CHAT_DB.createContentView = function () {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    return parseInt(callNativeApp(NATIVE_KEY_IOS.createContentView, {}));
  }
};

CHAT_DB.getToMoveGroupId = function () {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    return callNativeApp(NATIVE_KEY_IOS.getToMoveGroupId, {});
  }
};

CHAT_DB.getJoinCollaborationType = function () {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    return parseInt(
      callNativeApp(NATIVE_KEY_IOS.getJoinCollaborationType, {}),
      10
    );
  }
};

CHAT_DB.getHostRequestFlg = function () {
  // Androidは実装不要
  if (CHAT_UTIL.isIOS()) {
    return parseInt(callNativeApp(NATIVE_KEY_IOS.getHostRequestFlg, {}), 10);
  }
};
