官方文档
Android 离线SDK

博客基于 HBuilderX 3.99及以上版本,且未配置厂商推送

添加unipush依赖aar文件

SDK/libs

  • aps-release.aar
  • aps-unipush-release.aar

添加个推仓库

根目录 - build.gradle

项目根目录下配置个推仓库

allprojects {
repositories {
jcenter()
google()
// 个推的Maven仓地址。
maven {
url 'https://mvn.getui.com/nexus/content/repositories/releases'
}
}
}

项目目录 - build.gradle

android {
defaultConfig {
manifestPlaceholders = [
"GETUI_APPID": "【unipush的appid】",
"plus.unipush.appid" : "【unipush的appid】",
"plus.unipush.appkey" : "【unipush的key】",
"plus.unipush.appsecret": "【unipush的secret】",
"apk.applicationId":"io.dcloud.HBuilder"
]
}
}

dependencies {
implementation 'com.getui:gtsdk:3.3.3.0' //个推SDK
implementation 'com.getui:gtc:3.2.9.0' //个推核心组件
}

AndroidManifest.xml配置

io.dcloud.PandoraEntryActivity标签下追加intent-filter

<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>

dcloud_properties.xml配置

dcloud_properties.xml中添加如下配置,features节点与services节点必须同时配置!

<properties>
<features>
<feature name="Push" value="io.dcloud.feature.aps.APSFeatureImpl">
<module name="unipush" value="io.dcloud.feature.unipush.GTPushService"/>
</feature>
</features>
<services>
<service name="push" value="io.dcloud.feature.aps.APSFeatureImpl"/>
</services>
</properties>

最终涉及变动文件

后话

一定要仔细看官方教程贴,我一开是以为不用添加aar文件,只配置了个推的仓库,实际项目启动后发现一直是提示push 模块未打包

我觉得官方的文档写的很清楚,如果可以精练下文字和内容排版就更舒服了。