JPush Hbuilder API ONLY For Android

Reference way

var jpushModule = uni.requireNativePlugin("JG-JPush");
Copy the code

Stop push service

API – stopPush()

After calling this API, the JPush push service is completely stopped. If the push message is not received, all other API calls of aurora push are invalid and cannot be recovered by jpushInterface.init. You need to call resumePush to recover.

The sample

jpushModule.stopPush();
Copy the code

Restoring push Service

API – resumePush()

When this API is called, aurora push is fully functional again.

The sample

jpushModule.resumePush();
Copy the code

Restoring push Service

API – isPushStopped(CALLBACK)

Used to check whether the Push Service has been stopped

Parameters that

  • CALLBACK
The parameter name The parameter types Parameters that
code number 0 – Stopped 1 – Not stopped

The sample

jpushModule.isPushStopped(result= >{
				let code = result.code
			});
Copy the code

Configure the Channel API

API – setChannel(Object)

Dynamically configure channels with a higher priority than those configured in AndroidManifest

Parameters that

  • Object
The parameter name The parameter types Parameters that
channel string The channel you want to configure

The sample

jpushModule.setChannel({
					'channel':'channel_1'
				});    
Copy the code

Set the API to allow push time

API – setPushTime(Object)

By default, users are allowed to push at any time. Any time a push comes down, the client will receive it and display it.

Developers can call this API to set the time when push is allowed.

If a message is not received within that time, the SDK does this: the pushed notification is thrown away.

This is a purely client-side implementation, so it depends on whether the client time is accurate, time zone, and so on. This interface is only valid for notifications, and custom messages are not affected.

Parameters that

  • Object
The parameter name The parameter types Parameters that
pushTimeDays NumberArray 0 means Sunday, 1 means Monday, and so on. (7 days, int range 0 to 6 in Set)
pushTimeStartHour number Allowed start time for push (24 hours: startHour range is 0 to 23)
pushTimeEndHour number End time allowed for push (24-hour: endHour ranges from 0 to 23)

The sample

jpushModule.setPushTime({
					'pushTimeDays': [0.1.2].'pushTimeStartHour':0.'pushTimeEndHour':23
				});    
Copy the code

Set the notification silence time API

API – setSilenceTime(Object)

By default, when a user receives a push notification, the client may be prompted by a vibration, ringing, etc. However, users expect the “DO not Disturb” mode during sleep and meetings, which is also the concept of silent period.

Developers can call this API to set the silence period. If a message is received within this period, : There is no ringing or vibration.

Parameters that

  • Object
The parameter name The parameter types Parameters that
silenceTimeStartHour number Start time of mute period – hours (24 hours, range: 0 to 23)
silenceTimeStartMinute number Mute start time – min (range: 0 to 59)
silenceTimeEndHour number End time of mute period – Hours (24 hours, range: 0 to 23)
silenceTimeEndMinute number Mute end time – min (range: 0 to 59)

The sample

jpushModule.setSilenceTime({
					'silenceTimeStartHour':22.'silenceTimeStartMinute':30.'silenceTimeEndHour':8
                    'silenceTimeEndMinute':30
				});    
Copy the code

Set the API for reserving the number of recent notifications

API – setLatestNotificationNumber(Object)

With aurora push, you push a lot of notifications to the client, and if the user doesn’t deal with it, a lot of it stays there.

Developers can define different quantities by calling this API. By default, the last five notifications are reserved.

Only valid for notifications. By keeping the most recent, it means that if a new notification arrives, the oldest item in the list is removed. For example, to reserve the last five notifications. Assuming there are already five items displayed in the notification bar, item 1 will be removed when item 6 arrives.

Parameters that

  • Object
The parameter name The parameter types Parameters that
notificationMaxNumber number Maximum number of entries to display

The sample

jpushModule.setLatestNotificationNumber({
					'notificationMaxNumber':22
				});    
Copy the code

Stop push service

API – requestPermission()

On Android 6.0 and above systems, it is necessary to request some used permissions. For some used permissions of JPush SDK, it is necessary to request the following permissions, because these permissions are needed to make statistics more accurate and functions more rich, we suggest developers to call them.

“android.permission.READ_PHONE_STATE” “android.permission.WRITE_EXTERNAL_STORAGE” “android.permission.READ_EXTERNAL_STORAGE” “android.permission.ACCESS_FINE_LOCATIO

The sample

jpushModule.requestPermission();
Copy the code

Statistical analysis API

API – onResume() / onPause()

This API is used to collect statistics of “user duration”, “active Users”, and “open times of users”, and report the statistics to the server and display them to developers on the Portal.

The sample

// call when the page loads:
jpushModule.onResume();

// call when the page exits:
jpushModule.onPause();
Copy the code

Clear notification API

API – clearNotificationById()

This API provides the ability to clear a notification to clear a specified notification.

The sample

jpushModule.clearNotificationById();
Copy the code

API – clearAllNotifications()

This API provides the ability to clear notifications that are presented by JPush (excluding those presented by non-Jpush SDK);

The sample

jpushModule.clearAllNotifications();
Copy the code

Notification switch API

API – isNotificationEnabled(CALLBACK)

Check whether the notification switch of the current application is enabled

Parameters that

  • CALLBACK
The parameter name The parameter types Parameters that
code number -1 – Detection failure 0 – Disable 1 – Enable

The sample

jpushModule.isNotificationEnabled(result= >{//number
				let code = result.code
			});
Copy the code

Android vendors push notes

You need to configure the native Activity of the application. For details, see the integration document of each vendor.

When using aurora RESTAPI push for vendor push, you need to set the corresponding “URI_action” and “uri_activity” parameters.

If not configured, you will not be able to get the manufacturer notification click content.

This page is reserved for the Uniapp plug-in

Uniapp plug-in users can directly specify the following jump parameters, easily realize the manufacturer’s notification click event callback compatibility.

  • “uri_action”:”cn.jiguang.uniplugin_jpush.OpenClickActivity”,
  • “uri_activity”:”cn.jiguang.uniplugin_jpush.OpenClickActivity”

Custom Activity

If you have configured your own jump Activity to be compatible with plug-in notification click event callbacks, you can do this by calling the following native methods:

JSONObject thirdOpenNotification = JPushHelper.convertThirdOpenNotificationToMap(msgId, title, content, extras, data);
JPushHelper.sendNotifactionEvent(thirdOpenNotification, 0);
JPushHelper.saveOpenNotifiData(thirdOpenNotification, 0);
Copy the code