Jpush Aurora Push

Source: Internet
Author: User

Push-to-server sends notification messages to clients

<?xml version= "1.0" encoding= "Utf-8"? ><manifest Package= "Org.mobiletrain.a9_1jpush"xmlns:android= "Http://schemas.android.com/apk/res/android" > <Permission Android:name= "${applicationid}.permission." Jpush_message "Android:protectionlevel= "signature"/> <!--Required Some system-required permissions, such as access to the network, etc.--<uses-permission android:name= "${applicationid}.permi Ssion. 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 android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android: Name= "Android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name= "android.permission.WRITE_ SETTINGS "/> <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.ACCESs_wifi_state "/> <uses-permission android:name=" Android.permission.SYSTEM_ALERT_WINDOW "/> < Application Android:name=". MyApplication "Android:allowbackup= "true"Android:icon= "@mipmap/ic_launcher"Android:label= "@string/app_name"Android:supportsrtl= "true"Android:theme= "@style/apptheme" > <activity android:name= ". Mainactivity "> <intent-filter> <action android:name=" Android.intent.action.MAIN "/&gt                ; <category android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> &LT;/ACTIVITY&G        T <!--Rich Push core features since 2.0.6-<Activity Android:name= "Cn.jpush.android.ui.PopWinActivity"android:exported= "false"Android:theme= "@style/mydialogstyle" > </activity> <!--Required SDK Core Features--<Activity Android:name= "Cn.jpush.android.ui.PushActivity"android:configchanges= "Orientation|keyboardhidden"android:exported= "false"Android:theme= "@android: Style/theme.notitlebar" > <intent-filter> <action android:name= "cn.jpush.a                Ndroid.ui.PushActivity "/> <category android:name=" Android.intent.category.DEFAULT "/> <category android:name= "${applicationid}"/> </intent-filter> </activity> < !--Required SDK Core Features-<Service Android:name= "Cn.jpush.android.service.DownloadService"android:enabled= "true"android:exported= "false" > </service> <!--Required SDK Core Features-<!--configurable android:process parameters will Pushservi Ce 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"/&G                T <action android:name= "Cn.jpush.android.intent.REPORT"/> <action android:name= "Cn.jpush.android.int Ent. Pushservice "/> <action android:name=" Cn.jpush.android.intent.PUSH_TIME "/> </intent-f Ilter> </service> <!--Required SDK Core Features--<receiver Android:name= "Cn.jpush.android.service.PushReceiver"android:enabled= "true" android:exported  = "false" > <intent-filter android:priority= "$" > <action android:name= "Cn.jpush.and Roid.intent.NOTIFICATION_RECEIVED_PROXY "/> <!--Required Display notification BAR--<category an Droid:name= "${applicationid}"/> </intent-filter> <intent-filter> <a ction android:name= "Android.intent.action.USER_PRESENT"/> <action android:name= "Android.net.conn.CONN Ectivity_change "/> </intent-filter> <!--Optional-<intent-filter&gt                ; <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 Core Features-<receiver Android:name= "Cn.jpush.android.service.AlarmReceiver"android:exported= "false"/> <!--Required. Enable it can get statistics data with channel-to-<meta-Data Android:name= "Jpush_channel"Android:value= "Developer-default"/> <meta-Data Android:name= "Jpush_appkey"Android:value= "82426619de889cf8b2bea0e5"/> <!--</> values from the developer platform Appkey---<receiver android:name= ". Myreceiver "> <intent-filter> <!--Listener User click on the notification bar event---<action Andro Id:name= "Cn.jpush.android.intent.NOTIFICATION_OPENED"/> <action android:name= "cn.jpush.android.intent .                Registration "/> <action android:name=" Cn.jpush.android.intent.MESSAGE_RECEIVED "/> <action android:name= "Cn.jpush.android.intent.NOTIFICATION_RECEIVED"/> <category android:name= "O Rg.mobiletrain.a9_1jpush "/> </intent-filter> </receiver> <activity android:name =". Main2activity "> </activity> </application></manifest>
 Public classMyreceiverextendsBroadcastreceiver {//because the broadcast is registered in the manifest file, the context here is application's context,application context cannot be used directly to start a//Activity//if the broadcast is registered in activity, the context in the broadcast is the context of the activity and can be used directly to initiate a new activity@Override Public voidOnReceive (Context context, Intent Intent) {Bundle bundle=Intent.getextras ();//log.d (TAG, "onreceive-" + intent.getaction ());LOG.D ("GOOGLE_LENVE_FB", "OnReceive:" +intent.getaction ()); //get the Registration ID when the request is successful        if(JPushInterface.ACTION_REGISTRATION_ID.equals (Intent.getaction ())) {//triggered when a message is received}Else if(JPushInterface.ACTION_MESSAGE_RECEIVED.equals (Intent.getaction ())) {//System.out.println ("The custom message was received. Message content is: "+ bundle.getstring (jpushinterface.extra_message));LOG.D ("GOOGLE_LENVE_FB", "OnReceive:" +bundle.getstring (jpushinterface.extra_message)); LOG.D ("GOOGLE_LENVE_FB", "OnReceive:" +bundle.getstring (Jpushinterface.extra_extra)); //custom messages are not displayed in the notification bar, so developers are completely writing code to handle}Else if(JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals (Intent.getaction ())) {//System.out.println ("Notification received");LOG.D ("GOOGLE_LENVE_FB", "OnReceive: Receive Notification"); //You can do some statistics here, or do some other work.//If the user clicks the notification bar}Else if(JPushInterface.ACTION_NOTIFICATION_OPENED.equals (Intent.getaction ())) {Intent Intent1=NewIntent (context, main2activity.class);            Intent1.addflags (Intent.flag_activity_new_task);        Context.startactivity (INTENT1); } Else{LOG.D ("GOOGLE_LENVE_FB", "OnReceive: ========="); }    }}
* * Created by Wangsong on 2016/5/9. *Unique identifier of the REGISTRATION_ID device*alias: Unique identifier of the user*Tags: users can have more than one label* <p/> *Error: The specified recipient does not currently have any devices to register or set* 1whether the Jpush is initialized in the MyApplication class* 2The name attribute is added to the application node.* 3. Check that the Appkey is correct* 4. Check that the manifest files are merged correctly*/ Public classMyApplicationextendsApplication {@Override Public voidonCreate () {Super. OnCreate ();//Jpushinterface.init (this); //to set an alias for different users, a user can only set an alias//Jpushinterface.setalias (This, "QQ", NULL); //set tabs for different users, one user can set multiple tabs//set<string> Set = new hashset<> ();//Set.add ("WX");//Set.add ("WB");//Set.add ("QQ");//Set.add ("Weibo");//Jpushinterface.settags (this, set, null);    }}

Jpush Aurora Push

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.