BMXPushManager Protocol Reference
Conforms to NSObject
Declared in BMXPushManager.h
Overview
Push manager
Instance Methods
addDelegate:
- (void)addDelegate:(id<BMXPushServiceProtocol>)*aDelegate*
- (void)registerAPNs {
[[[BMXClient sharedClient] pushService] start];
[[[BMXClient sharedClient] pushService] addDelegate:self];
- (void)viewDidLoad {
[super viewDidLoad];
[self configCollectionView];
self.view.clipsToBounds = YES;
[[[BMXClient sharedClient] chatService] addDelegate:self];
- (void)addIMListener {
BMXClient *client = [BMXClient sharedClient];
[[client rosterService] addDelegate:self];
- (void)addIMListener {
BMXClient *client = [BMXClient sharedClient];
[[client rosterService] addDelegate:self];
[[client chatService] addDelegate:self];
- (void)addIMListener {
BMXClient *client = [BMXClient sharedClient];
[[client rosterService] addDelegate:self];
[[client chatService] addDelegate:self];
[[client userService] addDelegate:self];
- (void)addIMListener {
BMXClient *client = [BMXClient sharedClient];
[[client rosterService] addDelegate:self];
[[client chatService] addDelegate:self];
[[client userService] addDelegate:self];
[[client groupService] addDelegate:self];
addDelegate:delegateQueue:
- (void)addDelegate:(id<BMXPushServiceProtocol>)*aDelegate* delegateQueue:(dispatch_queue_t)*aQueue*
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.automaticallyAdjustsScrollViewInsets = NO;
self.account = [IMAcountInfoStorage loadObject];
[self getMyProfile];
[self setUpNavItem];
[self setupSubview];
[self loadMessages];
[self scrollToBottomAnimated:NO refresh:NO];
[[[BMXClient sharedClient] chatService] addDelegate:self delegateQueue:dispatch_get_main_queue()];
addPushListener:
Add chat listener
- (void)addPushListener:(id<BMXPushServiceProtocol>)*listener*
Parameters
listener
Listener
Discussion
Add chat listener
Declared In
BMXPushManager.h
bindDeviceToken:completion:
Push binding device token.
- (void)bindDeviceToken:(NSString *)*deviceToken* completion:(void ( ^ ) ( BMXError *error ))*aCompletionBlock*
Parameters
deviceToken
token device's push token
aCompletionBlock
Bind callback
Discussion
Push binding device token.
Declared In
BMXPushManager.h
clearAllNotifications
Used to remove all pushes displayed in Notification
- (void)clearAllNotifications
Discussion
Used to remove all pushes displayed in Notification
Declared In
BMXPushManager.h
clearNotification:
Used to remove the specified push displayed in Notification iOS 10 and over support to remove specified push by identifier For iOS 10 and earlier versions, remove all pushes if identifier is set to 0
- (void)clearNotification:(NSInteger)*notificationId*
Parameters
notificationId
If notificationId is set to 0, remove all pushes
Discussion
Used to remove the specified push displayed in Notification iOS 10 and over support to remove specified push by identifier For iOS 10 and earlier versions, remove all pushes if identifier is set to 0
Declared In
BMXPushManager.h
clearTagsByOperationId:
Clear tags of the push user.
- (void)clearTagsByOperationId:(NSString *)*operationId*
Parameters
operationId
Operation id. Corresponding notification reminder in callback notification.
Discussion
Clear tags of the push user.
Declared In
BMXPushManager.h
deleteTags:operationId:
Delete tags of the push user.
- (void)deleteTags:(NSArray<NSString*> *)*tags* operationId:(NSString *)*operationId*
Parameters
tags
User tag to delete
operationId
Operation id. Corresponding notification reminder in callback notification.
Discussion
Delete tags of the push user.
Declared In
BMXPushManager.h
getCertification
Get push certificate returned by server after login.
- (void)getCertification
Discussion
Get push certificate returned by server after login.
Declared In
BMXPushManager.h
getPushProfileForceRefresh:completion:
Get push user details, force pull from server-side if forceRefresh == true
- (void)getPushProfileForceRefresh:(BOOL)*forceRefresh* completion:(void ( ^ ) ( BMXPushUserProfile *profile , BMXError *aError ))*aCompletionBlock*
Parameters
forceRefresh
Whether to force pull from server, automatically if local fetch failed
profile Push user profile information, initially passing in a pointing-to-empty shared_ptr object, fetch the user profile information here after function returned.
Discussion
Get push user details, force pull from server-side if forceRefresh == true
Declared In
BMXPushManager.h
getTagsByOperationId:withCompletion:
Get tags of the push user.
- (void)getTagsByOperationId:(NSString *)*operationId* withCompletion:(void ( ^ ) ( NSArray *tags , BMXError *error ))*aCompletionBlock*
Parameters
operationId
Operation id. Corresponding notification reminder in callback notification.
aCompletionBlock
Get callback
Discussion
Get tags of the push user.
Declared In
BMXPushManager.h
getToken
Get user token to use after login.
- (void)getToken
Discussion
Get user token to use after login.
Declared In
BMXPushManager.h
loadLocalPushMessagesFromMessageId:size:directionType:completion:
Load push message stored in local database. Start with latest message if not specified
- (void)loadLocalPushMessagesFromMessageId:(long long)*reMsgId* size:(NSUInteger)*size* directionType:(BMXPushMessageDirection)*directionType* completion:(void ( ^ ) ( NSArray *messageList , BMXError *error ))*aCompletionBlock*
Parameters
reMsgId
Start id for loading pushes
size
Maximum number of searched messages
directionType
List of loaded local pushes returned by database
aCompletionBlock
Direction of loading pushes, default to load earlier messages
Discussion
Load push message stored in local database. Start with latest message if not specified
Declared In
BMXPushManager.h
removeDelegate:
- (void)removeDelegate:(id<BMXPushServiceProtocol>)*aDelegate*
removePushListener:
Remove chat listener
- (void)removePushListener:(id<BMXPushServiceProtocol>)*listener*
Parameters
listener
Listener
Discussion
Remove chat listener
Declared In
BMXPushManager.h
resume
Resume push function.
- (void)resume
Discussion
Resume push function.
Declared In
BMXPushManager.h
- (BOOL)canRecord
{
__block BOOL bCanRecord = YES;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
if ([audioSession respondsToSelector:@selector(requestRecordPermission:)]) {
[audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
bCanRecord = granted;
}];
}
return bCanRecord;
- (void)addContentView {
[self.view addSubview:self.contentView];
__weak ChangePasswordViewController *weakSelf = self;
self.contentView.changeBlock = ^(NSString * _Nonnull newPassword) {
[weakSelf changePasswordApi:newPassword];
};
messageModel.nickName = [roster.nickName length] ? roster.nickName : roster.userName;
[weakCell setMessageName:messageModel.nickName];
}
}];
} else {
messageModel.isChatGroup = NO;
}
messageCell.messageModel = messageModel;
MAXLog(@"%@", messageCell.messageModel.content);
return messageCell;
[[[BMXClient sharedClient] rosterService] searchByRosterId:messageModel.messageObjc.fromId forceRefresh:NO completion:^(BMXRoster *roster, BMXError *error) {
if (!error) {
if ([[NSFileManager defaultManager] fileExistsAtPath:roster.avatarThumbnailPath]) {
UIImage *avarat = [UIImage imageWithContentsOfFile:roster.avatarThumbnailPath];
[weakCell setAvaratImage:avarat];
}else {
[[[BMXClient sharedClient] rosterService] downloadAvatarWithRoster:roster isThumbnail:YES progress:^(int progress, BMXError *error) {
} completion:^(BMXRoster *roster, BMXError *error) {
if (!error) {
UIImage *avarat = [UIImage imageWithContentsOfFile:roster.avatarThumbnailPath];
[weakCell setAvaratImage:avarat];
}else {
[weakCell setAvaratImage:nil];
}
}];
-(void) setMainText:(NSString*) mainText detailText:(NSString*) detailText switcherFlag:(BOOL) switcherFlag switcherTarget:(__weak id) target switcherSelector:(nullable SEL) selector
{
[_line setHidden:NO];
_mainText.text = mainText;
if(detailText == nil) {
[_settingSwitch setHidden:NO];
[_detailText setHidden:YES];
_settingSwitch.on = switcherFlag;
if(selector != nil) {
[_settingSwitch addTarget:target action:selector forControlEvents:UIControlEventValueChanged];
}
}else {
_detailText.text = detailText;
[_settingSwitch setHidden:YES];
[_detailText setHidden:NO];
}
- (KeyboardEmojiModel *)findEmoji:(NSString *)string {
__block KeyboardEmojiModel *emotion;
for (KeyboardEmojiPackage *package in [KeyboardEmojiPackage loadPackages]) {
[package.emojis enumerateObjectsUsingBlock:^(KeyboardEmojiModel *item, NSUInteger idx, BOOL * _Nonnull stop) {
if ([item.name isEqualToString:string]) {
emotion = item;
}
}];
if (emotion) {
break;
}
}
return emotion;
- (KeyboardToolBar *)toolBarView {
if (!_toolBarView) {
_toolBarView = [KeyboardToolBar new];
__weak KeyboardVC *weakKeyBoard = self;
_toolBarView.emojiSend = ^() {
!weakKeyBoard.emojiSend ? : weakKeyBoard.emojiSend();
};
_toolBarView.backgroundColor = [UIColor lh_colorWithHex:0xffffff];
- (KeyboardEmojiTextView *)textView {
if (!_textView) {
LHWeakSelf
_textView = [KeyboardEmojiTextView new];
_textView.delegate = self;
_textView.backgroundColor = [UIColor whiteColor];
_textView.font = [UIFont systemFontOfSize:kChatInputTextViewFont];
_textView.returnKeyType = UIReturnKeySend;
_textView.enablesReturnKeyAutomatically = YES;
_textView.layer.borderColor = [UIColor lh_colorWithHex:0xe1e1e5].CGColor;
_textView.layer.borderWidth = 0.5;
_textView.showsVerticalScrollIndicator = YES;
_textView.showsHorizontalScrollIndicator = NO;
_textView.layer.cornerRadius = 5;
_textView.insertEmojiTextBlock = ^(UITextView *textView) {
[weakSelf textViewDidChange:textView];
};
_textView.layoutManager.allowsNonContiguousLayout = NO;
sendMessage:
Send a push uplink message and notify the listener of a change in message status
- (void)sendMessage:(NSString *)*message*
Parameters
message
Sent uplink push content
Discussion
Send a push uplink message and notify the listener of a change in message status
Declared In
BMXPushManager.h
alertView.btnClickBlock = ^{
UIImage *image = contentImg;
NSData *imageData = UIImageJPEGRepresentation(image,1.0f);
NSData *thumImageData = UIImageJPEGRepresentation(image,1.0f);
BMXImageAttachment *imageAttachment = [[BMXImageAttachment alloc] initWithData:imageData thumbnailData:thumImageData imageSize:image.size conversationId:[NSString stringWithFormat:@"%lld",group.groupId]];
imageAttachment.pictureSize = CGSizeMake(image.size.width, image.size.height);
IMAcount *account = [IMAcountInfoStorage loadObject];
BMXMessageObject *messageObject = [[BMXMessageObject alloc] initWithBMXMessageAttachment:imageAttachment fromId:[account.usedId longLongValue] toId:group.groupId type:BMXMessageTypeGroup conversationId:group.groupId];
messageObject.contentType = BMXContentTypeImage;
if (messageObject) {
[[[BMXClient sharedClient] chatService] sendMessage:messageObject];
- (void)sendTypingMessage:(NSDictionary *)configdic {
BMXMessageObject *messageObject = [[BMXMessageObject alloc] initWithBMXMessageText:@""
fromId:[self.account.usedId longLongValue]
toId:self.currentRoster.rosterId
type:BMXMessageTypeSingle
conversationId:self.currentRoster.rosterId];
messageObject.extensionJson = [NSString jsonStringWithDictionary:configdic];
messageObject.qos = DeliveryQosModeAtMostOnce;
[[[BMXClient sharedClient] chatService] sendMessage:messageObject];
self.lastTime = [NSString stringWithFormat:@"%f",messageModel.messageObjc.serverTimestamp * 0.001];
[self insertNewMessageOrTime:time];
// self.lastTime = time;
}
NSIndexPath *index = [self insertNewMessageOrTime:messageModel];
[self.messages addObject:messageModel];
[self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionBottom animated:YES];
if (messageObject) {
messageObject.clientTimestamp = [messageModel.date longLongValue];
[[[BMXClient sharedClient] chatService] sendMessage:messageObject];
_chatBarView.sendContent = ^(LHContentModel *content) {
[weakSelf sendMessage:content];
alertView.btnClickBlock = ^{
UIImage *image = contentImg;
NSData *imageData = UIImageJPEGRepresentation(image,1.0f);
NSData *thumImageData = UIImageJPEGRepresentation(image,1.0f);
BMXImageAttachment *imageAttachment = [[BMXImageAttachment alloc] initWithData:imageData thumbnailData:thumImageData imageSize:image.size conversationId:[NSString stringWithFormat:@"%lld",roster.rosterId]];
imageAttachment.pictureSize = CGSizeMake(image.size.width, image.size.height);
IMAcount *account = [IMAcountInfoStorage loadObject];
BMXMessageObject *messageObject = [[BMXMessageObject alloc] initWithBMXMessageAttachment:imageAttachment fromId:[account.usedId longLongValue] toId:roster.rosterId type:BMXMessageTypeSingle conversationId:roster.rosterId];
messageObject.contentType = BMXContentTypeImage;
if (messageObject) {
[[[BMXClient sharedClient] chatService] sendMessage:messageObject];
- (void)sendMessage:(LHContentModel *)content {
if (content.words && content.words.length) {
// 文字类型
[self p_configsendMessage:content.words type:MessageBodyType_Text duartion:0];
}
if (!content.photos && !content.photos.photos.count) return;
// 图片类型
[content.photos.photos enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL * stop) {
[self p_configsendMessage:image type:MessageBodyType_Image duartion:0];
}];
}
setBadge:
Set unread badge for push user.
- (void)setBadge:(int)*count*
Parameters
count
Unread badge count of user
Discussion
Set unread badge for push user.
Declared In
BMXPushManager.h
setPushMode:
Set push enabled state. Default enabled.
- (void)setPushMode:(BOOL)*enable*
Parameters
enable
Enabled state of push
Discussion
Set push enabled state. Default enabled.
Declared In
BMXPushManager.h
setPushTimeStartHour:endHour:
Set allowed push time.
- (void)setPushTimeStartHour:(int)*startHour* endHour:(int)*endHour*
Parameters
startHour
Start time for allowed silent push (hour)
endHour
End time for allowed silent push (hour)
Discussion
Set allowed push time.
Declared In
BMXPushManager.h
setSlienceTimeStartHour:endHour:
Set the start and end time of silent push.
- (void)setSlienceTimeStartHour:(int)*startHour* endHour:(int)*endHour*
Parameters
startHour
Start time for silent push (hour)
endHour
End time for silent push (hour)
Discussion
Set the start and end time of silent push.
Declared In
BMXPushManager.h
setTags:operationId:
Set tags of push user.
- (void)setTags:(NSArray<NSString*> *)*tags* operationId:(NSString *)*operationId*
Parameters
tags
User tag
operationId
Operation id. Corresponding notification reminder in callback notification.
Discussion
Set tags of push user.
Declared In
BMXPushManager.h
start
Initialize push sdk. Use this interface to initialize the push sdk in the case of using push only. When using IM features at the same time, call login function directly in BMXClient. The config object initializes by passing in the platform type and device id.
- (void)start
Discussion
Initialize push sdk. Use this interface to initialize the push sdk in the case of using push only. When using IM features at the same time, call login function directly in BMXClient. The config object initializes by passing in the platform type and device id.
Declared In
BMXPushManager.h
- (void)registerAPNs {
[[[BMXClient sharedClient] pushService] start];
- (YYTextHighlight *)_getHighlightAtPoint:(CGPoint)point range:(NSRangePointer)range {
if (!self._innerLayout.containsHighlight) return nil;
point = [self _convertPointToLayout:point];
YYTextRange *textRange = [self._innerLayout textRangeAtPoint:point];
if (!textRange) return nil;
NSUInteger startIndex = textRange.start.offset;
- (BOOL)isEqual:(YYTextRange *)object {
if (!object) return NO;
return [_start isEqual:object.start] && [_end isEqual:object.end];
- (YYTextRange *)_correctedRangeWithEdge:(YYTextRange *)range {
NSRange visibleRange = self.visibleRange;
YYTextPosition *start = range.start;
- (YYTextRange *)_correctedRangeWithEdge:(YYTextRange *)range {
NSRange visibleRange = self.visibleRange;
YYTextPosition *start = range.start;
YYTextPosition *end = range.end;
if (start.offset == visibleRange.location && start.affinity == YYTextAffinityBackward) {
start = [YYTextPosition positionWithOffset:start.offset affinity:YYTextAffinityForward];
}
if (end.offset == visibleRange.location + visibleRange.length && start.affinity == YYTextAffinityForward) {
end = [YYTextPosition positionWithOffset:end.offset affinity:YYTextAffinityBackward];
}
if (start != range.start || end != range.end) {
}
newPos = [self closestPositionToPoint:point];
if ([newPos compare:otherPosition] == [oldPosition compare:otherPosition] &&
newPos.offset != otherPosition.offset) {
return newPos;
}
if (_container.isVerticalForm) {
if ([oldPosition compare:otherPosition] == NSOrderedAscending) { // search backward
YYTextRange *range = [self textRangeByExtendingPosition:otherPosition inDirection:UITextLayoutDirectionUp offset:1];
if (range) return range.start;
if ([oldPosition compare:otherPosition] == NSOrderedAscending) { // search backward
YYTextRange *range = [self textRangeByExtendingPosition:otherPosition inDirection:UITextLayoutDirectionUp offset:1];
if (range) return range.start;
} else { // search forward
YYTextRange *range = [self textRangeByExtendingPosition:otherPosition inDirection:UITextLayoutDirectionDown offset:1];
if (range) return range.end;
}
} else {
if ([oldPosition compare:otherPosition] == NSOrderedAscending) { // search backward
YYTextRange *range = [self textRangeByExtendingPosition:otherPosition inDirection:UITextLayoutDirectionLeft offset:1];
if (range) return range.start;
// head or tail, returns immediately
if (!forwardMove && position.offset == visibleStart) {
return [YYTextRange rangeWithRange:NSMakeRange(_visibleRange.location, 0)];
} else if (forwardMove && position.offset == visibleEnd) {
return [YYTextRange rangeWithRange:NSMakeRange(position.offset, 0) affinity:YYTextAffinityBackward];
}
// extend from position
YYTextRange *fromRange = [self textRangeByExtendingPosition:position];
if (!fromRange) return nil;
YYTextRange *allForward = [YYTextRange rangeWithStart:fromRange.start end:[YYTextPosition positionWithOffset:visibleEnd]];
startWithAlias:
Initialize push sdk. Use this interface to initialize the push sdk in the case of using push only. When using IM features at the same time, call login function directly in BMXClient. The config object initializes by passing in the platform type and device id.
- (void)startWithAlias:(NSString *)*alias*
Parameters
alias
Current user alias used for push initialization
Discussion
Initialize push sdk. Use this interface to initialize the push sdk in the case of using push only. When using IM features at the same time, call login function directly in BMXClient. The config object initializes by passing in the platform type and device id.
Declared In
BMXPushManager.h
startWithAlias:bmxToken:
Initialize push sdk. Use this interface to initialize the push sdk in the case of using push only. When using IM features at the same time, call login function directly in BMXClient. The config object initializes by passing in the platform type and device id.
- (void)startWithAlias:(NSString *)*alias* bmxToken:(NSString *)*bmxToken*
Parameters
alias
Current user alias used for push initialization
bmxToken
User token passed in by App when push initialization.
Discussion
Initialize push sdk. Use this interface to initialize the push sdk in the case of using push only. When using IM features at the same time, call login function directly in BMXClient. The config object initializes by passing in the platform type and device id.
Declared In
BMXPushManager.h
status
Push the current state of sdk.
- (BMXPushSdkStatus)status
Discussion
Push the current state of sdk.
Declared In
BMXPushManager.h
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context{
if ([keyPath isEqualToString:@"status"]) {
AVPlayerItem * item = (AVPlayerItem *)object;
if (item.status == AVPlayerItemStatusReadyToPlay) {
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context{
if ([keyPath isEqualToString:@"status"]) {
AVPlayerItem * item = (AVPlayerItem *)object;
if (item.status == AVPlayerItemStatusReadyToPlay) {
[self.player play];
}else if (item.status == AVPlayerItemStatusFailed){
- (void)layoutSubviews {
[super layoutSubviews];
CGRect bubbleFrame = _bubbleView.frame;
bubbleFrame.origin.y = self.headImageView.frame.origin.y ;
if (self.messageModel.isChatGroup) {
bubbleFrame.origin.y = self.headImageView.frame.origin.y + 10;
}
if (self.messageModel.isSender) {
bubbleFrame.origin.y = self.headImageView.frame.origin.y;
// 菊花状态 (因不确定菊花具体位置,要在子类中实现位置的修改)
switch (self.messageModel.status) {
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if ([exportSession status] == AVAssetExportSessionStatusCompleted) {
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status]) {
AVAssetTrack* videoTrack = [videoTracks objectAtIndex:0];
UIImageOrientation orientation = [self orientationFromAVAssetTrack:videoTrack];
int m_pixelFormatType = kCVPixelFormatType_32BGRA;
NSDictionary* options = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt: (int)m_pixelFormatType] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
AVAssetReaderTrackOutput* videoReaderOutput = [[AVAssetReaderTrackOutput alloc] initWithTrack:videoTrack outputSettings:options];
[reader addOutput:videoReaderOutput];
[reader startReading];
while ([reader status] == AVAssetReaderStatusReading && videoTrack.nominalFrameRate > 0&&(!self.isCancelled)&&self.videoBlock) {
stop
Function interface for stop push
- (void)stop
Discussion
Function interface for stop push
Declared In
BMXPushManager.h
- (void)startRecordingWithFileName:(NSString *)fileName completion:(void(^)(NSError *error))completion {
NSError *error = nil;
if (![[BMXRecoderTools shareManager] canRecord]) {
if (completion) {
error = [NSError errorWithDomain:NSLocalizedString(@"error", NSLocalizedString(@"No_permission", @"没权限")) code:201 userInfo:nil];
completion(error);
}
return;
}
if ([self.recorder isRecording]) {
[_recorder stop];
- (void)stopRecordingWithCompletion:(void(^)(NSString *recordPath, int duration))completion
{
_endDate = [NSDate date];
if ([_recorder isRecording]) {
if ([_endDate timeIntervalSinceDate:_startDate] < [self recordMinDuration]) {
if (completion) {
completion(shortRecord, [self.endDate timeIntervalSinceDate:self.startDate]);
}
[self.recorder stop];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self.recorder stop];
- (void)cancelCurrentRecording
{
_recorder.delegate = nil;
if (_recorder.recording) {
[_recorder stop];
- (void)startPlayRecorder:(NSString *)recorderPath
{
[self.player stop];
- (void)stopPlayRecorder:(NSString *)recorderPath
{
[self.player stop];
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player
successfully:(BOOL)flag
{
[self.player stop];
- (void)enterMainAction:(UIButton *)btn {
[self stop];
unbindAlias:
Unbind user alias.
- (void)unbindAlias:(NSString *)*alias*
Parameters
alias
The user alias that needs to be unbound.
Discussion
Unbind user alias.
Declared In
BMXPushManager.h
Example: