dootask/app/Module/AppPush/AppPush.php
kuaifan 531129f48d feat(push): 移除友盟推送,APP 推送改为系统配置 / 自定义 / 关闭三档
- 删除友盟别名接口、模型、日志清理及 hedeqiang/umeng 依赖,迁移删除 umeng_alias / umeng_logs 表
- 系统配置(默认):通过官方 DooPush 共享通道自助注册租户,按 App 上报的推送 Token 绑定设备
- 自定义:沿用自有 DooPush 应用凭证;关闭:不推送也不记录设备
- 老站点升级后统一为系统配置,原自定义凭证保留
- PushUmengMsg 更名为 PushAppMsg;同步语言包、API 对照表与 ai-kb
2026-10-19 15:46:16 +00:00

51 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Module\AppPush;
use App\Module\Base;
class AppPush
{
/** 系统配置:官方 DooPush 共享通道(租户),设备 ID 由租户绑定返回 */
public const CHANNEL_SYSTEM = 'doopush_system';
/** 自定义:管理员自行配置的 DooPush 应用 */
public const CHANNEL_CUSTOM = 'doopush';
/**
* 推送模式:system(系统配置,默认)、custom(自定义)、close(关闭)
*/
public static function mode(): string
{
$mode = Base::setting('appPushSetting')['doopush'] ?? '';
return match ($mode) {
'custom' => 'custom',
'close' => 'close',
default => 'system',
};
}
public static function channel(): ?string
{
return match (self::mode()) {
'system' => self::CHANNEL_SYSTEM,
'custom' => self::CHANNEL_CUSTOM,
default => null,
};
}
public static function enabled(): bool
{
return self::mode() !== 'close';
}
/**
* @param array|int $userids
* @param array $msg [title, subtitle, body, description, extra, seconds, badge]
*/
public static function pushToUsers(array|int $userids, array $msg): void
{
app(DooPushClient::class)->pushToUsers($userids, $msg);
}
}