首选 uni.showLocalNotification,因其原生支持、零配置、不依赖厂商 SDK;适用于 App 进程存活时的定时提醒,但需满足 iOS ≥ 10、Android targetSdkVersion ≥ 26 等条件。

直接用 uni.showLocalNotification,别碰 plus.push.createMessage —— 后者根本不发通知,只是造了个内存对象。
为什么 uni.showLocalNotification 是首选
它原生支持、零配置、不依赖厂商 SDK,也不用改 manifest.json 或接入 uniPush。适合「用户开着 App 时的定时提醒」,比如打卡倒计时、日程弹窗、表单提交成功提示。
但它有硬性前提:App 进程得活着(前台或后台未被系统杀掉),且 iOS ≥ 10、Android targetSdkVersion ≥ 26。
- 时间戳必须是毫秒:
Date.now() + 60 * 1000(不是new Date().getSeconds()) - Android 必须传
channelId,否则静默;iOS 必须传sound,否则不响铃 - 调用前务必检查权限:
uni.getSetting看notification是否为authorized,否则uni.openSetting引导用户开启
plus.notification.create 能不能用
能,但限制极多,基本不推荐用于生产。
iOS 上 App 进入后台后调用直接失败,报错 "Not supported";Android 虽然可用,但必须提前用 plus.notification.setChannel 创建渠道,且 targetSdkVersion ≥ 26 才生效。
- 它和
uni.showLocalNotification的核心区别:前者是 H5+ 底层封装,后者是 uni-app 统一 API,兼容层更厚 - 如果你已深度依赖 H5+ API,且只跑 Android,可考虑它;否则优先走
uni.showLocalNotification - 千万别和
plus.push混用——plus.push.createMessage不触发通知栏,plus.push.send需服务端配合,两者都不是本地通知
上线前最容易失效的两个点
90% 的“通知不显示”问题都卡在这儿:
- Android 没声明通知渠道:即使代码里传了
channelId: 'default',也得在打包前确保plus.notification.setChannel({id: 'default', name: '默认通知' })被执行过(建议放在onLaunch) - iOS 没开 Background Modes:Xcode 工程里必须勾选
Background fetch和Remote notifications,否则 App 切后台后无法触发定时逻辑
这两个点不解决,测试机上可能正常,一上架就集体失效——因为真机系统策略比模拟器严得多。











