What is push?
A picture that lets you know what a push is:
This is the push:
Is that the server can send messages to the client in real time
There are several concepts to understand first:
Long connections and segment connections:
A long connection is a communication connection that is always established between the client and the server and can be communicated between the client and the server at any time before the connection is interrupted.
Short connection refers to the communication between the two parties have data interaction is to establish a connection, after the data is sent to complete, then disconnect this connection.
Instant communication implemented by long connections is called: push (that is, today's topic)
The instant communication implemented by a short connection is called: polling. (the client asks the server if there are any new messages every time)
Domestic third-party push platform:
Aurora Push
A push
Baidu Push Send
Xiaomi push
Wait a minute
Learn about Aurora push today.
First register an account on the official website: https://www.jiguang.cn/
Create an app, create an app's package name, and be consistent with the app package name you want to integrate with Aurora push
Refer to the development documentation step-by-step: http://docs.jiguang.cn/guideline/android_guide/#sdk
1. Download Android sdk:http://docs.jiguang.cn/resources/
2.
SDK Integration Steps Import SDK Development package to your own application project
- Unzip the Jpush-android-release-2.x.y.zip integrated compression package.
- Copy all the files under the Libs folder to the project Lib you created.
Configuration manifest file:
Configure the Androidmanifest.xml of the application project according to the Androidmanifest.xml sample file in the SDK compression package.
The main steps are:
- Copy the section with notes as "Required"
- Replace the comment as part of the replacement package name with the current application's package name
- Replace the Appkey with the key that registered the app on the portal, for example (9fed5bcb7b9b87413678c407)
androidmanifest example
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "Package=" you apply the package name "android:versioncode=" 216 "android:versionname=" 2.1.6 "> <uses-sdk android:m insdkversion= "9" android:targetsdkversion= "/>" <!--Required--<permission android:name= "The package name you applied. per Mission. Jpush_message "android:protectionlevel=" signature "/> <!--Required--<uses-permission android:name=" you The package name of the app. Permission.jpush_message "/> <uses-permission android:name=" Android.permission.RECEIVE_USER_PRESENT "/ > <uses-permission android:name= "Android.permission.INTERNET"/> <uses-permission android:name= "Android . permission. Wake_lock "/> <uses-permission android:name=" Android.permission.READ_PHONE_STATE "/> <uses-permission an Droid: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:name= " Android.permission.MOUNT_UNMOUNT_FILESYSTEMS "/> <uses-permission android:name=" android.permission.ACCESS_ Network_state "/> <uses-permission android:name=" Android.permission.WRITE_SETTINGS "/> <!--Optional. Required for location feature-<uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION"/& Gt <uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name= " Android.permission.CHANGE_WIFI_STATE "/> <uses-permission android:name=" android.permission.ACCESS_FINE_ Location "/> <uses-permission android:name=" Android.permission.ACCESS_LOCATION_EXTRA_COMMANDS "/> <uses -permission android:name= "Android.permission.CHANGE_NETWORK_STATE"/> <application android:icon= "@drawable /ic_launcher "android:label=" @string/app_name "Android:name= "Your Application" > <!--Required SDK Core Features-<!--option since 2.0.5 configurable Pushservic The android:process parameter of the E,daemonservice,pushreceiver,alarmreceiver sets the Jpush related component to a separate process-<!--such as: android:process= ": Remote"--<service android:name= "Cn.jpush.android.service.PushService" Android:enab Led= "true" android:exported= "false" > <intent-filter> <action Android:nam E= "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 Optional. 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.DaemonService"/> <category android:name= "The package name you applied"/> </intent-filter> </service> < ;! --Required---<receiver android:name= "Cn.jpush.android.service.PushReceiver" Android: Enabled= "true" > <intent-filter android:priority= "$" > <action android:name= "Cn.jpu Sh.android.intent.NOTIFICATION_RECEIVED_PROXY "/> <category android:name=" The package name you applied "/> & lt;/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.PAC kage_added "/> <action android:name=" Android.intent.action.PACKAGE_REMOVED "/> < Data android:scheme= "package"/> </intent-filter> </receiver> <!--Required SDK core functions Can-<activity android:name= "cn.jpush.android.ui.PushActivity" android:configchanges= "O Rientation|keyboardhidden "android:exported=" false "> <intent-filter> <ac tion android:name= "cn.jpush.android.ui.PushActivity"/> <category android:name= "Android.intent.catego Ry. DEFAULT "/> <category android:name=" The package name you applied/> </intent-filter> </activ Ity> <!--Required SDK Core Features--<service android:name= "Cn.jpush.android.service.Downloa Dservice "Android:enabled= "true" android:exported= "false" > </service> <!--Required SDK Core features--& Gt <receiver android:name= "Cn.jpush.android.service.AlarmReceiver"/> <!--User defined. User-defined broadcast receivers--<receiver android:name= "your own defined receiver" android:enabled= "true" > <intent-filter> <!--Required User Registration SDK intent--> <action Android:na Me= "Cn.jpush.android.intent.REGISTRATION"/> <!--Required user receives the SDK message intent--> & Lt;action android:name= "Cn.jpush.android.intent.MESSAGE_RECEIVED"/> <!--Required user receives SDK notification bar information inte nt--> <action android:name= "Cn.jpush.android.intent.NOTIFICATION_RECEIVED"/> &L t;! --required user opens intent--> <action android:name= "Cn.jpush.android.intent.NOTIFICATION_OPENED" of the custom notification bar > <!--OPtional user accepts the rich Push Javascript callback function intent--> <action android:name= "Cn.jpush.android.intent.ACTION _richpush_callback "/> <!--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"/> </inte Nt-filter> </receiver> <!--Required. For publish channel feature-<!--Jpush_channel is a handy way for developers to count APK distribution channels. -<!--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= "Your AppKey"/> < ;/application></manifest>
finally initialized in mainactivity (typically initialized in application, here)
public class Mainactivity extends Activity { @Override protected void onCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main); Jpushinterface.setdebugmode (TRUE);//test with jpushinterface.init (this); } }
Now it's done!
Android Aurora Push Learning