Skip to content
能力中心
产品中心
应用市场
WebOffice
开发者后台

消息通知

是否接收消息推送通知

配置是否接收消息推送通知,配置对当前账号下所有设备生效,默认为true。

获取配置

代码示例

Swift
let canReceivePushNoti = KIM.setting.canReceivePushNotification
Objective-c
BOOL canReceivePushNoti = KIM.setting.canReceivePushNotification;

更新配置

接口定义

Swift
 // 更新设置
func updateCanReceivePushNotificationSetting(value: Bool, complete: ((KIMError?) -> Void)? = nil)

参数说明

参数类型说明
valueBool不在应用内是否推送消息
true: 推送
false: 不推送
complete((KIMError?) -> Void)? = nil完成回调
error:错误信息,成功时为nil

代码示例

Swift
KIM.setting.updateCanReceivePushNotificationSetting(value: true) { error in
    if error == nil {
        // 设置成功
    }
}
Objective-c
[KIM.setting updateCanReceivePushNotificationSettingWithValue:YES complete:^(KIMError *error) {
    if (error == nil) {
        // 设置成功
    }
}];

桌面端在线时本机不接收消息推送通知

配置桌面端在线时本机不接收消息推送通知,配置对当前账号及当前设备生效,默认为true。

获取配置

代码示例

Swift
let notReceivePushNotiWhenPCOnline = KIM.setting.notReceivePushNotificationWhenPCOnline
Objective-c
BOOL notReceivePushNotiWhenPCOnline = KIM.setting.notReceivePushNotificationWhenPCOnline;

更新配置

接口定义

Swift
 // 更新设置
func updateNotReceivePushNotificationWhenPCOnlineSettingWithValue(value: Bool, complete: ((KIMError?) -> Void)? = nil)

参数说明

参数类型说明
valueBool桌面在线时是否推送消息
true: 不推送
false: 推送
complete((KIMError?) -> Void)? = nil完成回调
error:错误信息,成功时为nil

代码示例

Swift
KIM.setting.updateNotReceivePushNotificationWhenPCOnlineSetting(value: true) { error in
    if error == nil {
        // 设置成功
    }
}
Objective-c
[KIM.setting updateNotReceivePushNotificationWhenPCOnlineSettingWithValue:YES complete:^(KIMError *error) {
    if (error == nil) {
        // 设置成功
    }
}];

通知栏是否显示消息详情

配置通知栏是否显示消息详情,配置对当前账号及当前设备生效,默认为true。

获取配置

代码示例

Swift
let pushNotiDisplayDetail = KIM.setting.pushNotificationDisplayDetail
Objective-c
BOOL pushNotiDisplayDetail = KIM.setting.pushNotificationDisplayDetail;

更新配置

接口定义

Swift
 // 更新设置
func updatePushNotificationDisplayDetailSetting(value: Bool, complete: ((KIMError?) -> Void)? = nil)

参数说明

参数类型说明
valueBool不在应用内,推送的消息是否显示消息详情
true: 显示详情
false: 不显示详情
completecomplete: ((KIMError?) -> Void)? = nil完成回调
error:错误信息,成功时为nil

代码示例

Swift
KIM.setting.updatePushNotificationDisplayDetailSetting(value: true) { error in
    if error == nil {
        // 设置成功
    }
}
Objective-c
[KIM.setting updatePushNotificationDisplayDetailSettingWithValue:YES complete:^(KIMError *error) {
    if (error == nil) {
        // 设置成功
    }
}];

通话和会议邀请通知

配置是否接收通话和会议邀请推送通知,配置对当前账号所有设备生效,默认为true。

获取配置

代码示例

Swift
let canReceiveMeetingPushNoti = KIM.setting.canReceiveMeetingPushNotification
Objective-c
BOOL canReceiveMeetingPushNoti = KIM.setting.canReceiveMeetingPushNotification;

更新配置

接口定义

Swift
 // 更新设置
func updateCanReceiveMeetingPushNotificationSetting(value: Bool, complete: ((KIMError?) -> Void)? = nil)

参数说明

参数类型说明
valueBool配置是否接收通话和会议邀请推送通知
true: 接收
false: 不接收
completecomplete: ((KIMError?) -> Void)? = nil完成回调
error:错误信息,成功时为nil

代码示例

Swift
KIM.setting.updateCanReceiveMeetingPushNotificationSetting(value: true) { error in
    if error == nil {
        // 设置成功
    }
}
Objective-c
[KIM.setting updateCanReceiveMeetingPushNotificationSettingWithValue:YES complete:^(KIMError *error) {
    if (error == nil) {
        // 设置成功
    }
}];

应用内显示通知横幅

在应用内,是否显示通知横幅,配置对当前账号及当前设备生效。

获取配置

代码示例

Swift
let isShowNotificationInForeground = KIM.setting.showNotificationInForeground
Objective-c
BOOL isShowNotificationInForeground = [KIM.setting showNotificationInForeground];

更新配置

代码示例

Swift
// 设置应用内是否显示通知横幅
KIM.setting.showNotificationInForeground = true
Objective-c
// 设置应用内是否显示通知横幅
[KIM.setting setShowNotificationInForeground: YES]

横幅显示消息详情

在应用内显示消息的前提下,是否显示消息详情,配置对当前账号及当前设备生效。

获取配置

代码示例

Swift
let isForegroundNotificationDisplayDetail = KIM.setting.foregroundNotificationDisplayDetail
Objective-c
BOOL isForegroundNotificationDisplayDetail = [KIM.setting foregroundNotificationDisplayDetail];

更新配置

代码示例

Swift
// 开启横幅显示消息详情
KIM.setting.foregroundNotificationDisplayDetail = true
Objective-c
// 开启横幅显示消息详情
[KIM.setting setForegroundNotificationDisplayDetail:YES];

通话和会议中关闭通知横幅

在应用内通话和会议状态下,是否关闭通知横幅,配置对当前账号及当前设备生效。

获取配置

代码示例

Swift
let isShowForegroundNotificationWhileInMeeting = KIM.setting.showForegroundNotificationWhileInMeeting
Objective-c
BOOL isShowForegroundNotificationWhileInMeeting = [KIM.setting showForegroundNotificationWhileInMeeting];

更新配置

代码示例

Swift
// 设置通话和会议中关闭通知横幅
KIM.setting.showForegroundNotificationWhileInMeeting = true
Objective-c
// 设置通话和会议中关闭通知横幅
[KIM.setting setShowForegroundNotificationWhileInMeeting:YES];

添加设置监听

部分设置会让当前账号下的所有设备生效,通过该方法添加设置监听,可以接收到相关修改通知。

方法定义

Swift
func addSettingListener(delegate: KIMSettingDelegate)
Objective-c
- (void)addSettingListenerWithDelegate:(id <KIMSettingDelegate>)delegate;

参数说明

参数类型说明
delegateKIMSettingDelegate监听代理

KIMSettingDelegate 说明:

方法参数说明
didUpdateSetting(_ setting: KIMSetting)setting: KIMSetting对象,可通过该对象调用相关配置属性获取最新配置。当相关设置被更新后通过该回调方法通知,通过setting对象取到的属性值为最新值。

代码示例

  1. 添加设置监听。
Swift
KIM.setting.addSettingListener(delegate: self)
Objective-c
[KIM.setting addSettingListenerWithDelegate:self];
  1. 实现 KIMSettingDelegate 代理方法。
Swift
func didUpdateSetting(setting: KIMSetting) {
    //  setting.canReceivePushNotification
}
Objective-c
- (void)didUpdateSetting:(KIMSetting *)setting {
    //  setting.canReceivePushNotification
}