默认构造函数
BasicCustomPushNotification的默认构造函数,所有配置采用默认设置:通知方式采用震动+通知;NotificationFlag采用Notification.FLAG_AUTO_CANCEL,状态栏图标用的是android.R.drawable.stat_notify_chat。
接口定义
public BasicCustomPushNotification();
构造函数
接口定义
public BasicCustomPushNotification(int drawable, int flags, int remindType);
参数说明
参数 | 类型 | 是否必填 | 说明 |
drawable | int | 是 | 状态栏图标 |
flags | int | 是 | NotificationFlags,支持系统Notification下的Flag参数 |
remindType | int | 是 | 提醒方式类型,支持以下选择:
|
代码示例
new BasicCustomPushNotification(R.drawable.logo, Notification.FLAG_AUTO_CANCEL, BasicCustomPushNotification.REMIND_TYPE_VIBRATE_AND_SOUND);
获取状态栏图标
获取已设置的状态栏图标。
接口定义
public int getStatusBarDrawable()
代码示例
int drawable = (new BasicCustomPushNotification()).getStatusBarDrawable();
设置状态栏图标
更改状态栏图标设置。
接口定义
public void setStatusBarDrawable(int statusBarDrawable);
参数说明
参数 | 类型 | 是否必填 | 说明 |
statusBarDrawable | int | 是 | 状态栏图标资源ID |
代码示例
(new BasicCustomPushNotification()).setStatusBarDrawable(R.drawable.logo);
获取提醒方式
获取已经设置的提醒方式。
接口定义
public int getRemindType();
代码示例
int type = (new BasicCustomPushNotification()).getRemindType();
设置提醒方式
更改自定义通知的提醒方式。
接口定义
public void setRemindType(int remindType);
参数说明
参数 | 类型 | 是否必填 | 说明 |
remindType | int | 是 | 提醒方式类型,支持以下选择:
|
代码示例
(new BasicCustomPushNotification()).setRemindType(BasicCustomPushNotification.REMIND_TYPE_VIBRATE_AND_SOUND);
获取Notification Flags参数
获取已经设置的notification flags参数。
接口定义
public int getNotificationFlags();
代码示例
int type = (new BasicCustomPushNotification()).getNotificationFlags();
设置Notification Flags参数
更改自定义通知的flags参数。
接口定义
public void setNotificationFlags(int notificationFlags);
参数说明
参数 | 类型 | 是否必填 | 说明 |
notificationFlags | int | 是 | 支持系统自带的Notification Flag参数 |
代码示例
(new BasicCustomPushNotification()).setNotificationFlags(Notification.FLAG_AUTO_CANCEL);
获取是否服务端设置优先
利用OpenAPI或者阿里云推送控制台推送消息都可以设置提醒方式,当后端设置的提醒方式和自定义样式提醒方式冲突时,SDK根据serverOptionFirst
参数来判断提醒方式策略。如果该参数为true,则采用后端设定的提醒方式;如果该参数为false,则采用自定义样式指定的提醒方式。默认为false
接口定义
public boolean isServerOptionFirst();
代码示例
boolean isServerOptionFirst = (new BasicCustomPushNotification()).isServerOptionFirst();
设置是否服务端优先
更改自定义通知的serverOptionFirst参数。
接口定义
public void setServerOptionFirst(boolean serverOptionFirst);
参数说明
参数 | 类型 | 是否必填 | 说明 |
serverOptionFirst | boolean | 是 | 是否服务器配置优先。
默认值为false。 |
代码示例
(new BasicCustomPushNotification()).setServerOptionFirst(true);
获取推送前台到达是否创建通知参数
当推送到达时,如果应用处在前台,用户可以通过自定义样式决定是否创建通知。默认是创建通知。
接口定义
public boolean isBuildWhenAppInForeground();
代码示例
boolean isBuildWhenAppInForeground = (new BasicCustomPushNotification()).isBuildWhenAppInForeground();
设置推送前台到达是否创建通知参数
更改当推送到达时应用处在前台的情况下是否创建通知的设置。
接口定义
public void setBuildWhenAppInForeground(boolean buildWhenAppInForeground);
参数说明
参数 | 类型 | 是否必填 | 说明 |
buildWhenAppInForeground | boolean | 是 | 是否创建通知 |
代码示例
(new BasicCustomPushNotification()).setBuildWhenAppInForeground(false);
- 本页导读 (0)