/**
 * 调用unipush云函数发送推送
 * @param {Array} userIds - 要推送的用户ID数组
 * @param {String} title - 推送标题
 * @param {String} content - 推送内容
 * @param {Object} payload - 推送额外数据
 * @param {String} appId - 应用ID（可选）
 * @returns {Promise} 推送结果
 */
export const sendPushNotification = async ({
  userIds,
  title,
  content,
  msgId,
  payload = {},
  appId = null
}) => {
  console.log(userIds);
  try {
    const result = await uniCloud.callFunction({
      name: 'unipush',
      data: {
        type: 'sendMessage',
        userIds: userIds,
        title: title,
        msgId,
        content: content,
        payload: payload,
        appId: appId
      }
    });

    return result.result;
  } catch (error) {
    console.error('发送推送失败:', error);
    throw error;
  }
};
