vmei-day04-Jcenter方式集成极光推送
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                vmei-day04-Jcenter方式集成极光推送
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                今天主要寫了一個小demo來集成極光推送的功能到項目
 
第一步,先看proj_gradle配置:
??
buildscript {repositories {jcenter()}dependencies {classpath 'com.android.tools.build:gradle:2.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files //添加內容 // classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' } }// this script was used to upload files to bintray. //apply from: 'bintray.gradle' allprojects {repositories {jcenter()} }task clean(type: Delete) {delete rootProject.buildDir } 主要添加 // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files //添加內容 // classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' // Top-level build file where you can add configuration options common to all sub-projects/modules.2.再看app.gradle配置
android {compileSdkVersion 23 buildToolsVersion "24.0.2" defaultConfig {applicationId "com.example.maguitao.demo" minSdkVersion 21 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" ndk {//選擇要添加的對應cpu類型的.so庫 abiFilters 'armeabi', 'armeabi-v7a', 'armeabi-v8a' //還可以添加 'armeabi-v7a', 'x86' }manifestPlaceholders = [JPUSH_PKGNAME : "com.example.maguitao.demo",//包名字JPUSH_APPKEY : "9389b8bad8346cece74fb112", //JPush上注冊的包名對應的appkey. JPUSH_CHANNEL : "developer-default", //暫時填寫默認值即可. ]} } 添加依賴compile 'cn.jiguang.sdk:jpush:3.0.0' // 此處以JPush 3.0.0 版本為例。 compile 'cn.jiguang.sdk:jcore:1.0.0' // 此處以JCore 1.0.0 版本為例。,最后就是清單文件的配置了:
<!-- 以下是極光推送的配置--> <!-- Required SDK 核心功能--> <!-- 可配置android:process參數將PushService放在其他進程中 --> <service android:name="cn.jpush.android.service.PushService" android:enabled="true" android:exported="false" ><intent-filter><action android:name="cn.jpush.android.intent.REGISTER" /><action android:name="cn.jpush.android.intent.REPORT" /><action android:name="cn.jpush.android.intent.PushService" /><action android:name="cn.jpush.android.intent.PUSH_TIME" /></intent-filter></service><!-- since 1.8.0 option 可選項。用于同一設備中不同應用的JPush服務相互拉起的功能。 --> <!-- 若不啟用該功能可刪除該組件,將不拉起其他應用也不能被其他應用拉起 --> <service android:name="cn.jpush.android.service.DaemonService" android:enabled="true" android:exported="true"><intent-filter ><action android:name="cn.jpush.android.intent.DaemonService" /><category android:name="com.example.maguitao.demo"/></intent-filter></service><!-- Required SDK核心功能--> <receiver android:name="cn.jpush.android.service.PushReceiver" android:enabled="true" ><intent-filter android:priority="1000"><action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /><category android:name="com.example.maguitao.demo"/></intent-filter><intent-filter><action android:name="android.intent.action.USER_PRESENT" /><action android:name="android.net.conn.CONNECTIVITY_CHANGE" /></intent-filter><!-- Optional --> <intent-filter><action android:name="android.intent.action.PACKAGE_ADDED" /><action android:name="android.intent.action.PACKAGE_REMOVED" /><data android:scheme="package" /></intent-filter></receiver><!-- Required SDK核心功能--> <activity android:name="cn.jpush.android.ui.PushActivity" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar" android:exported="false" ><intent-filter><action android:name="cn.jpush.android.ui.PushActivity" /><category android:name="android.intent.category.DEFAULT" /><category android:name="com.example.maguitao.demo" /></intent-filter></activity><!-- Required SDK核心功能--> <service android:name="cn.jpush.android.service.DownloadService" android:enabled="true" android:exported="false" ></service><!-- Required SDK核心功能--> <receiver android:name="cn.jpush.android.service.AlarmReceiver" /><!-- User defined. For test only 用戶自定義的廣播接收器--> <receiver android:name="brodcast.MyReceiver" android:exported="false" android:enabled="true"><intent-filter><action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required 用戶注冊SDK的intent--> <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required 用戶接收SDK消息的intent--> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required 用戶接收SDK通知欄信息的intent--> <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!--Required 用戶打開自定義通知欄的intent--> <action android:name="cn.jpush.android.intent.CONNECTION" /><!-- 接收網絡變化 連接/斷開 since 1.6.3 --> <category android:name="com.example.maguitao.demo" /></intent-filter></receiver><!-- Required. For publish channel feature --> <!-- JPUSH_CHANNEL 是為了方便開發者統計APK分發渠道。--> <!-- 例如: --> <!-- 發到 Google Play 的APK可以設置為 google-play; --> <!-- 發到其他市場的 APK 可以設置為 xxx-market。 --> <!-- 目前這個渠道統計功能的報表還未開放。--> <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/><!-- Required. AppKey copied from Portal --> <meta-data android:name="JPUSH_APPKEY" android:value="9389b8bad8346cece74fb112"/> <!-- 極光推送配置完成-->
,,然后就是java代碼里面自己初始化
private void initJiguang() {JPushInterface.setDebugMode(true);JPushInterface.init(this); }到此完成
demo的下載地址在我個人分享里面:極光推送和環信智能機器人.ZIP
總結
以上是生活随笔為你收集整理的vmei-day04-Jcenter方式集成极光推送的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: sqlserver实验心得体会_sql查
- 下一篇: WORD中的多级列表详解
