Integrated Jpush
1. Create a demo with Android studio
2. Create a laser push developer account, to create an Aurora push developer account, visit the Aurora Push official website Https://www.jiguang.cn/push
3. Create an app on the portal
Log in with your registered account and enter the Aurora console and click on the "Create App" button. Once you've created your account to go to Aurora, the first thing you'll see is the interface to create the app. Fill in the name of your application and the two items on the Android package name.
4. Manual integration, import related files http://docs.jiguang.cn/jpush/client/Android/android_guide/
Note: In Android studio, you need to create a JNI folder, and in the name of Jnilibs, the so file is directed in.
Copy the resources in the Res. drawable-hdpi,layout,values file into the same directory as the created project
3. Configure Androidmanifest.xml
3.1 Add permission (note change the name of the package)
<Permission Android:name= "The package name you applied. Permission.jpush_message"Android:protectionlevel= "signature"/> <uses-permission android:name= "The package name you applied. Permission.jpush_message"/> <uses-permission Android Oid:name= "Android.permission.RECEIVE_USER_PRESENT"/> <uses-permission android:name= " Android.permission.INTERNET "/> <uses-permission android:name=" Android.permission.WAKE_LOCK "/> <uses-p Ermission android:name= "Android.permission.READ_PHONE_STATE"/> <uses-permission android:name= " Android.permission.WRITE_EXTERNAL_STORAGE "/> <uses-permission android:name=" android.permission.READ_ External_storage "/> <uses-permission android:name=" Android.permission.VIBRATE "/> <uses-permission Android Oid:name= "Android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> <uses-permission android:name= " Android.permission.ACCESS_NETWORK_STATE "/> <uses-permission android:name=" android.permission.WRITE_ SETTINGS "/> <uses-permission android:name=" Android.permission.ACCESS_WIFI_STATE "/>
3.2 Copy the core code (determined to change the package name and Appkey)
<!--Required SDK Core Features--<!--configurable android:process parameters put Pushservice in other processes--<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"/&G T </intent-filter> </service> <!--since 1.8.0 option available. The ability to pull together Jpush services for different applications in the same device. -<!--If you do not enable this feature to remove the component, it will not pull up other apps or be pulled by other apps-<Service Android:name= "Cn.jpush.android.service.DaemonService"android:enabled= "true"android:exported= "true" > <intent-filter > <action android:name= "Cn.jpush.android.intent.DaemonServ Ice "/> <category android:name=" The package name you applied/> </intent-filter> </service > <!--Required SDK Core Features--<receiver Android:name= "Cn.jpush.android.service.PushReceiver"android:enabled= "true" > <intent-filter android:priority= "$" > <action android:name= "Cn.jpush.andr Oid.intent.NOTIFICATION_RECEIVED_PROXY "/> <category android:name=" The package name you applied "/> </int ent-filter> <intent-filter> <action android:name= "Android.intent.action.USER_PRESENT "/> <action android:name=" Android.net.conn.CONNECTIVITY_CHANGE "/> </intent-filter& Gt <!--Optional--<intent-filter> <action android:name= "Android.intent.action.PAC kage_added "/> <action android:name=" Android.intent.action.PACKAGE_REMOVED "/> < Data android:scheme= "package"/> </intent-filter> </receiver> <!--Required SDK Core Features-<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= "Package name you apply"/> </intent-filter> </activity> <!--SDK Core features--<Activity Android:name= "Cn.jpush.android.ui.PopWinActivity"android:configchanges= "Orientation|keyboardhidden"android:exported= "false"Android:theme= "@style/mydialogstyle" > <intent-filter> <category android:name= "android.intent.cate Gory. DEFAULT "/> <category android:name=" The package name you applied/> </intent-filter> </activ Ity> <!--Required SDK Core Features-<Service Android:name= "Cn.jpush.android.service.DownloadService"android:enabled= "true"android:exported= "false" > </service> <!--Required SDK core functions--<receiver android:name= "Cn.jpush.and Roid.service.AlarmReceiver "/> <!--User defined. User-definable broadcast receivers-<receiver Android:name= "Receiver of your own definition"android:enabled= "true" > <intent-filter> <!--Required User Registration SDK intent--> <act Ion Android:name= "Cn.jpush.android.intent.REGISTRATION"/> <!--Required user receives the SDK message intent--> <action android:name= "Cn.jpush.android.intent.MESSAGE_RECEIVED"/> <!--Required user access intent--> <action android:name= "Cn.jpush.android.intent.NOTIFICATION_RECEIVED"/> for receiving SDK notification bar information <!--Required user to open the intent--> <action android:name= "Cn.jpush.android.intent.NOTIF of the custom notification bar Ication_opened "/> <!--receive network changes connect/disconnect since 1.6.3--<action Android:name=" cn . Jpush.android.intent.CONNECTION "/> <category android:name=" The package name you applied "/> </intent-f Ilter> </receiver> <!--Required. For publish channel feature-<!--Jpush_channel is a handy way for developers to count APK distribution channels. --&Gt <!--For example:-<!--to Google Play apk can be set to Google-play; -<!--to other markets APK can be set to Xxx-market. -<!--The current report on this channel stats feature is not yet open. --<meta-data android:name= "Jpush_channel" android:value= "Developer-default"/> <!--Required. AppKey copied from Portal to <meta-data android:name= "Jpush_appkey" android:value= "AppKey of your Application"/>
4. Create your own broadcast receiver Myreceiver
/*** Custom Receiver * <p> * If this receiver is not defined, then: * 1) The default user will open the main interface * 2) cannot receive custom messages*/ Public classMyreceiverextendsBroadcastreceiver {Private Static FinalString TAG = "Jpush"; Privatelist<string> list =NewArraylist<>(); Public voidOnReceive (Context context, Intent Intent) {Bundle bundle=Intent.getextras (); if(JPushInterface.ACTION_REGISTRATION_ID.equals (Intent.getaction ())) {String Regid=bundle.getstring (jpushinterface.extra_registration_id); LOG.D (TAG,"[Myreceiver] Receive registration Id:" +Regid); } Else if(JPushInterface.ACTION_MESSAGE_RECEIVED.equals (Intent.getaction ())) {LOG.D (TAG,"A custom message was received. The message content is: "+bundle.getstring (jpushinterface.extra_message)); //custom messages are not displayed in the notification bar, so developers are completely writing code to handleString Content=bundle.getstring (jpushinterface.extra_message); Toast.maketext (context, content, Toast.length_short). Show (); } Else if(JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals (Intent.getaction ())) {//You can do some statistics here, or do some other work.}Else if(JPushInterface.ACTION_NOTIFICATION_OPENED.equals (Intent.getaction ())) {String content=bundle.getstring (jpushinterface.extra_alert);//here, we take out the content of the notification. You can also take out other information, which you can handle yourself.//Here you can write your own code to define the behavior after the user clicksIntent i =NewIntent (context, testactivity.class); I.putextra ("Content", content); I.setflags (Intent.flag_activity_new_task); Context.startactivity (i); } Else { } }}
5. Confusion with integrated Jpush Android SDK
Add the following configuration in the project's obfuscation file Proguard.jar
--class cn.jpush.*class cn.jiguang.* {;}
6. Registration (preferably registered in application)
Jpushinterface.init ( this
In this way, the program can receive the push message in the Aurora push console.
Android Aurora Push Integration