更新记录
0.0.3(2025-11-24)
调整项目结构
0.0.2(2025-11-24)
调整项目结构
0.0.1(2025-11-24)
[0.0.1] - 2025-11-24
added
- support android functions
- upport firebase cloud messaging get fcm token
- support firebase cloud messaging subscribe
- support firebase cloud messaging unsubscribe
平台兼容性
uni-app(4.85)
| Vue2 | Vue2插件版本 | Vue3 | Vue2插件版本 | Chrome | Safari | app-vue | app-vue插件版本 | app-nvue | app-nvue插件版本 | Android | Android插件版本 | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| √ | 0.0.3 | √ | 0.0.3 | × | × | √ | 0.0.3 | √ | 0.0.3 | 7.0 | 0.0.3 | - | × |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|
| × | × | × | × | × | × | × | × | × | × | × |
uni-app x(4.85)
| Chrome | Safari | Android | Android插件版本 | iOS | 鸿蒙 | 微信小程序 |
|---|---|---|---|---|---|---|
| × | × | 7.0 | 0.0.3 | × | × | × |
其他
| 多语言 | 暗黑模式 | 宽屏模式 |
|---|---|---|
| √ | √ | √ |
unifcm
features
- [x] 支持获取google firebase cloud messaging registrationToken
- [x] 支持添加主题订阅(方便做大批量推送)
- [x] 支持取消主题订阅
- [x] 支持消息监听
usage
- 登陆firebase控制台,获取应用的google-service.json
- 打开google-service.json文件,复制appId, projectId, apiKey,三个必须参数
- 在项目的app.vue的onLaunch里面引入插件并用步骤2的3个参数初始化fcm
import { GmInit } from "@/uni_modules/gm-unifcm"; onLaunch: function() { GmInit("appId", "projectId", "apiKey") } - 在需要监听消息的页面在onMounted页面周期内使用GmOnMessage监听
onMounted(() => { GmOnMessage((title, body, data) => { console.log(`收到Fcm推送: title: ${title}, body: ${body}, data: ${data}`); }) }) - 获取token
import { GmGetToken } from "@/uni_modules/gm-unifcm"; GmGetToken({ success: (token) => { console.log(`Fcm Token: ${token}'`); }, }) - 增加订阅
import { GmSubscribe } from "@/uni_modules/gm-unifcm"; GmSubscribe(true, 'topic', { success: () => { console.log('订阅成功') }, fail: (res) => { console.log('订阅失败', res) } }) - 取消订阅
import { GmSubscribe } from "@/uni_modules/gm-unifcm"; GmSubscribe(false, 'topic', { success: () => { console.log('取消订阅成功') }, fail: (res) => { console.log('取消订阅失败', res) } })增加订阅与取消订阅方法一样,请注意 第一个参数 \ true: 表示订阅 \ false: 表示取消订阅 \
plan todo next
- [ ] support ios
author
青峰

收藏人数:
购买普通授权版(
试用
赞赏(0)
下载 6
赞赏 0
下载 11310380
赞赏 1810
赞赏
京公网安备:11010802035340号