uniapp离线打包

geteshi
2025-11-21 / 0 评论 / 9 阅读 / 正在检测是否收录...

超详细!uni-app Android本地打包傻瓜式教程

1. 接入mPaaS,支付宝原生扫码插件

支付宝原生扫码插件 - DCloud 插件市场

uniapp里面按照上面的配置

离线打包的时候,增加下面的配置

image-20251121133250438

<meta-data android:name="mobilegw.appid" android:value=""/>
<meta-data android:name="workspaceId" android:value=""/>
<meta-data android:name="mpaasConfigLicense" android:value=""/>

在main\assets目录下,增加一个dcloud_uniplugins.json文件,我是根据插件目录里面的配置写的

{
  "nativePlugins": [
    {
      "plugins": [
        {
          "type": "module",
          "name": "Mpaas-Scan-Module",
          "class": "com.mpaas.uniapp.scan.MpaasScanModule"
        }
      ]
    }
  ]
}

image-20251121134553314

将插件目录下的android,里面的所有内容,都复制到libs里面

image-20251121134717222

image-20251121134817490

然后正常打包就行了

2. push2.0相关

image-20251121134930583

maven {
    url 'https://mvn.getui.com/nexus/content/repositories/releases'
}

image-20251121134951586

<service name="push" value="io.dcloud.feature.aps.APSFeatureImpl"/>

image-20251121135243398

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:host="io.dcloud.unipush" android:path="/" android:scheme="unipush" />
</intent-filter>

image-20251121135941913

// 个推相关
manifestPlaceholders = [
        "GETUI_APPID"           : "GETUI_APPID",
        "plus.unipush.appid"    : "GETUI_APPID",
        "plus.unipush.appkey"   : "AppKey",
        "plus.unipush.appsecret": "AppSecret",
        "apk.applicationId"     : "包名:比如com.test.app"
]

在hb项目里面,右键,新增云函数,提交到线上,便可使用

const uniPush = uniCloud.getPushManager({appId: "你的应用appId"}) //注意这里需要传入你的应用appId
exports.main = async (event, context) => {
    let push = {
        "push_clientid": "",  # 填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
        "force_notification": True,  # 填写true,客户端就会对在线消息自动创建“通知栏消息”。
        "title": "通知栏显示的标题",
        "content": "通知栏显示的内容",
        "settings": {
            # 消息有效期设置,单位毫秒,-1表示不设离线。默认是 2 小时,取值范围:-1 ~ 3 * 24 * 3600 * 1000(3天)之间
            "ttl": 86400000
        },
        "payload": {
            "text": "体验一下uni-push2.0"
        },
        "badge": "+1"
    }
    return await uniPush.sendMessage(push)
}

dcloud的云空间,记得添加这三张表

image-20251121140218233

0

评论 (0)

取消