极光推送自动集成工具


说明 : 使用jcenter自动集成的开发者,不需要在项目中添加jar和so,jcenter会自动完成依赖;在AndroidManifest.xml中不需要添加任何JPush SDK 相关的配置,jcenter会自动导入。
  • AndroidManifest配置

    <service android:name="cn.jpush.android.service.PushService"
          android:process=":multiprocess"
          tools:node="replace" >
    </service>
    
  • android defaultConfig配置

    ndk {
        abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
    }repositories {
        manifestPlaceholders = [
                JPUSH_PKGNAME : applicationId,
                JPUSH_APPKEY : "你的appkey",
                JPUSH_CHANNEL : "developer-default",
        ]
    }
    buildscript {
        repositories {
            jcenter()    }
    }
    allprojets {
        repositories {
            jcenter()
        }
    }

依赖:

    compile 'cn.jiguang.sdk:jpush:3.1.1'
    compile 'cn.jiguang.sdk:jcore:1.1.9'

gradle.properties文件中添加:
android.useDeprecatedNdk=true
 
 
//Activity的方法
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
    }


说明:若没有res/drawable-xxxx/jpush_notification_icon这个资源默认使用应用图标作为通知icon,在5.0以上系统将应用图标作为statusbar icon可能显示不正常,用户可定义没有阴影和渐变色的icon替换这个文件,文件名不要变。

猜你喜欢

转载自blog.csdn.net/a821265960/article/details/79623578