效果图(这里就简单实现了别名推送和广播(所有人)的推送功能):
1、先从build.gradle配置文件入手
2、需要下载资源包
3、添加一些重要的类
4、AndroidManifest.xml
build.gradle配置文件入手(需要加入红框中的代码,我这里就直接展示我的配置文件):
build.gradle配置文件(Appkey换成自己的):
apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.0" defaultConfig { applicationId "com.example.test_push" minSdkVersion 24 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" manifestPlaceholders = [ JPUSH_PKGNAME: applicationId, JPUSH_APPKEY : "Appkey", //JPush 上注册的包名对应的 Appkey. JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可. ] } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } sourceSets { main { jniLibs.srcDirs = ['libs'] } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' }
下载资源包点我获取(提取码:ccd4,)