This commit is contained in:
2025-10-19 21:51:00 +08:00
parent 7b60fb965f
commit c7d738ccce
11 changed files with 624 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package com.taskttl.core.notification
/**
* 通知管理器
* @author admin
* @date 2025/10/16
* @constructor 创建[NotificationManager]
*/
expect object NotificationManager {
/**
* 日程通知
* @param [payload] 有效载荷
*/
suspend fun scheduleNotification(payload: NotificationPayload)
/**
* 取消通知
* @param [id] ID
*/
suspend fun cancelNotification(id: String)
/**
* 全部取消
*/
suspend fun cancelAll()
}

View File

@@ -0,0 +1,20 @@
package com.taskttl.core.notification
/**
* 通知有效载荷
* @author admin
* @date 2025/10/16
* @constructor 创建[NotificationPayload]
* @param [id] ID
* @param [title] 标题
* @param [message] 消息
* @param [triggerTimeMillis] 触发时间毫秒
* @param [repeatType] 重复类型
*/
data class NotificationPayload(
val id: String,
val title: String,
val message: String,
val triggerTimeMillis: Long,
val repeatType: NotificationRepeatType = NotificationRepeatType.NONE,
)

View File

@@ -0,0 +1,31 @@
package com.taskttl.core.notification
/**
* 通知权限回调接口
*/
interface NotificationPermissionCallback {
/**
* 授予
*/
fun onGranted()
/**
* 被否认
*/
fun onDenied()
}
/**
* 跨平台通知权限处理器
*/
expect object NotificationPermissionManager {
/**
* 请求通知权限
* @return 是否允许
*/
fun requestPermission(callback: NotificationPermissionCallback)
fun verifyPermission(): Boolean
fun disablePermission()
}

View File

@@ -0,0 +1,14 @@
package com.taskttl.core.notification
/**
* 通知重复类型
* @author admin
* @date 2025/10/16
* @constructor 创建[NotificationRepeatType]
*/
enum class NotificationRepeatType {
NONE,
DAILY,
WEEKLY,
MONTHLY
}