Aurora push jpush

Source: Internet
Author: User
Tags ranges
1. Set

Androidmanifest. xml
Libs/jpush-SDK-Release 1. x. y. Jar
Libs/armeabi/libsys 1. x. y. So

2. Basic API
  • Init initialization SDK

  • Setdebugmode

3. mycycler
/* ** Custom receiver ** if this receiver is not defined, the following will be performed: * 1) by default, the user will open the main interface * 2) custom message not received */public class mycycler extends broadcastreceiver {Private Static final string tag = "mycycler"; @ override public void onreceive (context, intent) {bundle = intent. getextras (); log. D (TAG, "onreceive-" + intent. getaction () + ", extras:" + printbundle (bundle); If (jpushinterface. action_registration_id.equals (intent. getaction () {string regid = bundle. getstring (jpushinterface. extra_registration_id); log. D (TAG, "receive registration ID:" + regid); // send the registration ID to your server ...} else if (jpushinterface. action_unregister.equals (intent. getaction () {string regid = bundle. getstring (jpushinterface. extra_registration_id); log. D (TAG, "receive unregistration ID:" + regid); // send the unregistration ID to your server ...} else if (jpushinterface. action_message_received.equals (intent. getaction () {log. D (TAG, "custom message received:" + bundle. getstring (jpushinterface. extra_message);} else if (jpushinterface. action_icationication_received.equals (intent. getaction () {log. D (TAG, "notification received after push"); int notifactionid = bundle. getint (jpushinterface. extra_icationication_id); log. D (TAG, "ID of the notification to be pushed:" + notifactionid);} else if (jpushinterface. action_icationication_opened.equals (intent. getaction () {log. D (TAG, "user clicked to open the notification"); // open the custom activity intent I = new intent (context, testactivity. class); I. setflags (intent. flag_activity_new_task); context. startactivity (I);} else {log. D (TAG, "unhandled intent-" + intent. getaction () ;}}// print all intent extra data Private Static string printbundle (bundle) {stringbuilder sb = new stringbuilder (); For (string key: bundle. keyset () {If (key. equals (jpushinterface. extra_icationication_id) {sb. append ("nkey:" + key + ", value:" + bundle. getint (key);} else {sb. append ("nkey:" + key + ", value:" + bundle. getstring (key) ;}} return sb. tostring ();}}
4. Customize notification styles

Customize notification styles such as sound, vibration, and flashing.

Basicpushnotificationbuilder builder = new basicpushnotificationbuilder (mainactivity. this); builder. statusbardrawable = R. drawable. jpush_notification_icon; builder. icationicationflags = notification. flag_auto_cancel; // set to automatically disappear builder. notificationults ults = notification. default_sound | notification. default_vibrate; // jpushinterface is required for the ringtone and vibration. setpushnotificationbuilder (1, builder );
5. Advanced custom notification styles

Based on the basic pushnotificationbuilder, You can further customize the notification layout.

Custompushnotificationbuilder builder = new custompushnotificationbuilder (mainactivity. this, R. layout. customer_notitfication_layout, R. id. icon, R. id. title, R. id. text); // specify the custom notification layoutbuilder. statusbardrawable = R. drawable. your_notification_icon; // specify the top-level status bar icon builder. layouticondrawable = R. drawable. your_2_icationication_icon; // specifies the notification icon jpushinterface displayed in the drop-down status bar. setpushnotificationbuilder (2, builder );
6. Set the number of recent notifications to be retained

5 by default

public static void setLatestNotifactionNumber(Context context, int maxNum)
7. Set the push time allowed
public static void setPushTime(Context context, Set<Integer> weekDays, int startHour, int int endHour)

Parameter description
Applicationcontext of the context context application
Set days 0 indicates Sunday, 1 indicates Monday, and so on. (In 7 days, the int range in the Set set is 0 to 6)
Sdk1.2.9-new function: If the set value is null, messages and notifications can be received at any time. If the set size is 0, messages and notifications cannot be received at any time.
Int starthour: Start time allowed for pushing (in 24-hour format: starthour ranges from 0 to 23)
Int endhour: the end time allowed for pushing (in 24-hour format: endhour ranges from 0 to 23)

8. aliases and tags
public static void setAliasAndTags(Context context, String alias, Set<String> tags)

Call this API to set both aliases and tags.
It should be understood that ** this interface covers the logic, not the incremental logic. That is, the new call overwrites the previous settings. **
After a call, if you need to change the alias and tag again, you only need to call this API again.

When Android calls this interface, we recommend that you use the sorted hashset for the set implementation to ensure the sorted set. In this way, when you call more than 100 tags interfaces, ensure that the first 100 are successfully set by jpush.

Parameter Definition
Alias
Null this value is not set for this call. (Note: not the string "null ")
"" (Empty string) indicates canceling the previous settings.
Set a valid alias for each call to overwrite the previous settings.
Valid aliases: uppercase/lowercase letters, numbers, underscores, and Chinese characters.
Restriction: the length of Alias naming is limited to 40.

Tags
Null this value is not set for this call. (Note: not the string "null ")
An empty array or list indicates that the previous settings are canceled.
Set at least one tag for each call, overwrite the previous settings, instead of adding a new tag.
Valid tags: uppercase/lowercase letters, numbers, underscores, and Chinese characters.
Limit: The name length of each tag is limited to 40. A maximum of 100 tags can be set, but the total length cannot exceed 1 kb.

9. Notifications and custom messages

Notification
Or push notification, that is, a notification message displayed on the notification bar (status bar) of the mobile phone. This is the basic function of Android/IOS.
For a notification, simply enter the text-only notification content.
Notifications are mainly used to prompt users. The application adds the notification function to improve the application activity.

Custom message
Is the concept of Aurora push.
The custom message is not a notification, so it is not displayed in the notification bar by the SDK. The content is completely defined by developers.
Custom messages are mainly used for internal business logic of applications. A custom message may not be displayed on any page.


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.