资讯中心 / MobPush——免费app消息推送的API接口介绍

MobPush——免费app消息推送的API接口介绍

免费app消息推送
2018-11-26

MobPush是一款免费的app消息推送产品,app主只需要在app内植入MobPush SDK就可以快速集成app的消息推送功能。MobPush支持多种消息形式,开发者可主动及时的和用户发起交互,比如说发送聊天消息、日程提醒、活动预告、进度提示、动态更新等,目前,MobPush提供的通知、自定义消息及本地通知,是可以覆盖大多数推送场景的。下面是MobPush-API接口的介绍:

 

1. 消息监听接口

MobPushReceiver: 消息监听接口(包含接收自定义消息、通知消息、通知栏点击事件、别名和标签变更操作等)

MobPush.addPushReceiver(MobPushReceiver receiver): 设置消息监听

MobPush.removePushReceiver(MobPushReceiver receiver): 移除消息监听

 

2. 推送开关控制接口

MobPush.stopPush(): 停止推送(停止后将不会收到推送消息,仅可通过restartPush重新打开)

MobPush.restartPush(): 重新打开推送服务

MobPush.isPushStopped(): 判断推送服务是否已经停止

 

3. 推送选项接口

MobPush.setSilenceTime(int startHour, int startMinute, int endHour, int endMinute): 设置通知静音时段(开始时间小时和分钟、结束时间小时和分钟)

MobPush.setCustomNotification(MobPushCustomNotification customNotification): 设置自定义通知样式

 

4. 业务接口

MobPush.getRegistrationId(MobPushCallback<String> callback):获取注册id(可与用户id绑定,实现向指定用户推送消息)

别名操作:(同时只能设置一个别名,可用来标识一个用户)

MobPush.setAlias(String alias):设置别名

MobPush.getAlias():获取当前设置的别名

MobPush.deleteAlias():删除别名

标签操作:(同时可设置多个标签,可用于多用户订阅标签的方式,批量推送消息)

MobPush.addTags(String[] tags):添加标签

MobPush.getTags():获取所有已添加的标签

MobPush.deleteTags(String[] tags):删除标签

MobPush.cleanTags():清除所有已添加的标签

MobPushCustomeMessage: 自定义消息实体类

MobPushNotifyMessage: 通知消息实体类

 

5. 本地通知

MobPush.addLocalNotification(MobPushLocalNotification notification):添加本地通知

MobPush.removeLocalNotification(int notificationId):移除本地通知

MobPush.clearLocalNotifications():清空本地通知

MobPushLocalNotification:本地通知消息实体类,继承MobPushNotifyMessage

 

6. API错误码

API返回的错误码说明如下:(详见MobPushErrorCode.java说明)

-1 网络请求失败

-2 请求错误

 

上一篇 下一篇
SDK打包中 — 0%

SDK下载

正在根据您选择的SDK打包中,完成后自动下载
0%