更新记录

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

  1. 登陆firebase控制台,获取应用的google-service.json
  2. 打开google-service.json文件,复制appId, projectId, apiKey,三个必须参数
  3. 在项目的app.vue的onLaunch里面引入插件并用步骤2的3个参数初始化fcm
    import { GmInit } from "@/uni_modules/gm-unifcm";
    onLaunch: function() {
    GmInit("appId", "projectId", "apiKey")
    }
  4. 在需要监听消息的页面在onMounted页面周期内使用GmOnMessage监听
    onMounted(() => {
    GmOnMessage((title, body, data) => {
        console.log(`收到Fcm推送: title: ${title}, body: ${body}, data: ${data}`);
    })
    })
  5. 获取token
    import { GmGetToken } from "@/uni_modules/gm-unifcm";
    GmGetToken({
    success: (token) => {
        console.log(`Fcm Token: ${token}'`);
    },
    })
  6. 增加订阅
    import { GmSubscribe } from "@/uni_modules/gm-unifcm";
    GmSubscribe(true, 'topic', {
    success: () => {
        console.log('订阅成功')
    },
    fail: (res) => {
        console.log('订阅失败', res)
    }
    })
  7. 取消订阅
    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

青峰

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。