通知
This commit is contained in:
@@ -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()
|
||||
|
||||
}
|
||||
@@ -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,
|
||||
)
|
||||
@@ -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()
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.taskttl.core.notification
|
||||
|
||||
/**
|
||||
* 通知重复类型
|
||||
* @author admin
|
||||
* @date 2025/10/16
|
||||
* @constructor 创建[NotificationRepeatType]
|
||||
*/
|
||||
enum class NotificationRepeatType {
|
||||
NONE,
|
||||
DAILY,
|
||||
WEEKLY,
|
||||
MONTHLY
|
||||
}
|
||||
Reference in New Issue
Block a user