Agora RTC Objective-C API Reference Refactor

AgoraRtmClientKit.h
Go to the documentation of this file.
1 //
2 // AgoraRtmClientKit.h
3 // AgoraRtcKit
4 //
5 // Copyright (c) 2022 Agora. All rights reserved.
6 //
7 #import <Foundation/Foundation.h>
8 #import "AgoraRtmObjects.h"
9 @protocol AgoraRtmClientDelegate <NSObject>
10 @optional
11
17 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
18 didReceiveLinkStateEvent:(AgoraRtmLinkStateEvent * _Nonnull)event NS_SWIFT_NAME(rtmKit(_:didReceiveLinkStateEvent:));
19
25 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
26 didReceiveMessageEvent:(AgoraRtmMessageEvent * _Nonnull)event NS_SWIFT_NAME(rtmKit(_:didReceiveMessageEvent:));
27
34 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
35 didReceivePresenceEvent:(AgoraRtmPresenceEvent * _Nonnull)event NS_SWIFT_NAME(rtmKit(_:didReceivePresenceEvent:));
36
42 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
43 didReceiveLockEvent:(AgoraRtmLockEvent * _Nonnull)event NS_SWIFT_NAME(rtmKit(_:didReceiveLockEvent:));
44
51 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
52 didReceiveStorageEvent:(AgoraRtmStorageEvent * _Nonnull)event NS_SWIFT_NAME(rtmKit(_:didReceiveStorageEvent:));
53
61 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
62 didReceiveTopicEvent:(AgoraRtmTopicEvent * _Nonnull)event NS_SWIFT_NAME(rtmKit(_:didReceiveTopicEvent:));
63
70 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
71 tokenPrivilegeWillExpire:(NSString * _Nullable)channel NS_SWIFT_NAME(rtmKit(_:tokenPrivilegeWillExpire:));
72
81 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)kit
82 channel:(NSString * _Nonnull)channelName
83 connectionChangedToState:(AgoraRtmClientConnectionState)state
84 reason:(AgoraRtmClientConnectionChangeReason)reason NS_SWIFT_NAME(rtmKit(_:channel:connectionChangedToState:reason:));
85 @end
86
87 NS_ASSUME_NONNULL_BEGIN
98 __attribute__((visibility("default"))) @interface AgoraRtmClientKit : NSObject
99
100 - (instancetype _Nullable)init NS_UNAVAILABLE;
101
113 - (instancetype _Nullable)initWithConfig:(AgoraRtmClientConfig * _Nonnull)config
114 delegate:(id <AgoraRtmClientDelegate> _Nullable)delegate
115 error:(NSError**)error NS_SWIFT_NAME(init(_:delegate:));
116
124 - (void) loginByToken:(NSString* _Nullable)token
125 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(login(_:completion:));
126
133 - (void) logout:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(logout(_:));
134
141 - (AgoraRtmStorage* _Nullable)getStorage NS_SWIFT_NAME(getStorage());
142
149 - (AgoraRtmLock* _Nullable)getLock NS_SWIFT_NAME(getLock());
150
157 - (AgoraRtmPresence* _Nullable)getPresence NS_SWIFT_NAME(getPresence());
158
165 - (AgoraRtmHistory* _Nullable) getHistory NS_SWIFT_NAME(getHistory());
166
175 - (void) renewToken:(NSString* _Nonnull)token
176 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(renewToken(_:completion:));
177
186 - (void) subscribeWithChannel:(NSString* _Nonnull)channelName
187 option:(AgoraRtmSubscribeOptions* _Nullable)subscribeOption
188 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(subscribe(channelName:option:completion:));
189
197 - (void) unsubscribeWithChannel:(NSString* _Nonnull)channelName
198 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(unsubscribe(_:completion:));
208 - (void) publish:(NSString* _Nonnull)channelName
209 message:(NSString* _Nonnull)message
210 option:(AgoraRtmPublishOptions* _Nullable)publishOption
211 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(publish(channelName:message:option:completion:));
212
222 - (void) publish:(NSString* _Nonnull)channelName
223 data:(NSData* _Nonnull)data
224 option:(AgoraRtmPublishOptions* _Nullable)publishOption
225 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(publish(channelName:data:option:completion:));
226
233 - (void) addDelegate:(id <AgoraRtmClientDelegate> _Nonnull)delegate NS_SWIFT_NAME(addDelegate(_:));
234
241 - (void) removeDelegate:(id <AgoraRtmClientDelegate> _Nonnull)delegate NS_SWIFT_NAME(removeDelegate(_:));
250 - (AgoraRtmErrorCode)setParameters:(NSString* _Nonnull)parameter NS_SWIFT_NAME(setParameters(_:));
251
258 + (NSString* _Nullable)getErrorReason:(AgoraRtmErrorCode)errorCode NS_SWIFT_NAME(getErrorReason(_:));
264 + (NSString * _Nonnull)getVersion NS_SWIFT_NAME(getVersion());
265
266
276 - (AgoraRtmStreamChannel * _Nullable)createStreamChannel:(NSString * _Nonnull)channelName
277 error:(NSError**)error NS_SWIFT_NAME(createStreamChannel(_:));
278
279
287 - (AgoraRtmErrorCode)destroy NS_SWIFT_NAME(destroy());
288 @end
289
290 NS_ASSUME_NONNULL_END
291
292 __attribute__((visibility("default"))) @interface AgoraRtmStreamChannel : NSObject
293
294 - (instancetype _Nullable)init NS_UNAVAILABLE;
302 - (void)joinWithOption:(AgoraRtmJoinChannelOption * _Nonnull)option
303 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(join(_:completion:));
304
311 - (void)leave:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(leave(_:));
312
321 - (void)renewToken:(NSString* _Nonnull)token
322 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(renewToken(_:completion:));
323
332 - (void) joinTopic:(NSString * _Nonnull)topic
333 option:(AgoraRtmJoinTopicOption * _Nullable)option
334 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(joinTopic(_:option:completion:));
335
343 - (void) leaveTopic:(NSString * _Nonnull)topic
344 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(leaveTopic(_:completion:));
345
354 - (void) subscribeTopic:(NSString * _Nonnull)topic
355 option:(AgoraRtmTopicOption * _Nullable)option
356 completion:(AgoraRtmTopicSubscriptionBlock _Nullable)completionBlock NS_SWIFT_NAME(subscribeTopic(_:option:completion:));
357
358
367 - (void) unsubscribeTopic:(NSString * _Nonnull)topic
368 option:(AgoraRtmTopicOption * _Nullable)option
369 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(unsubscribeTopic(_:option:completion:));
370
380 - (void) publishTopicMessage:(NSString * _Nonnull)topic
381 message:(NSString * _Nonnull)message
382 option:(AgoraRtmTopicMessageOptions * _Nullable)options
383 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(publishTopicMessage(topic:message:option:completion:));
384
385
395 - (void) publishTopicMessage:(NSString * _Nonnull)topic
396 data:(NSData * _Nonnull)data
397 option:(AgoraRtmTopicMessageOptions * _Nullable)options
398 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(publishTopicMessage(topic:data:option:completion:));
406 - (void) getSubscribedUserList:(NSString* _Nonnull)topic
407 completion:(AgoraRtmGetTopicSubscribedUsersBlock _Nullable)completionBlock NS_SWIFT_NAME(getSubscribedUserList(_:completion:));
408
414 - (NSString * _Nonnull)getChannelName NS_SWIFT_NAME(getChannelName());
415
424 - (AgoraRtmErrorCode)setParameters:(NSString* _Nonnull)parameters NS_SWIFT_NAME(setParameters(_:));
425
433 - (AgoraRtmErrorCode)destroy;
434
435 @end
436
437 __attribute__((visibility("default"))) @interface AgoraRtmStorage : NSObject
438
439 - (instancetype _Nullable)init NS_UNAVAILABLE;
451 - (void) setChannelMetadata:(NSString * _Nonnull)channelName
452 channelType:(AgoraRtmChannelType)channelType
453 data:(AgoraRtmMetadata* _Nonnull)data
454 options:(AgoraRtmMetadataOptions* _Nullable)options
455 lock:(NSString * _Nullable)lock
456 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(setChannelMetadata(channelName:channelType:data:options:lock:completion:));
457
469 - (void) updateChannelMetadata:(NSString * _Nonnull)channelName
470 channelType:(AgoraRtmChannelType)channelType
471 data:(AgoraRtmMetadata* _Nonnull)data
472 options:(AgoraRtmMetadataOptions* _Nullable)options
473 lock:(NSString * _Nullable)lock
474 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(updateChannelMetadata(channelName:channelType:data:options:lock:completion:));
475
487 - (void) removeChannelMetadata:(NSString * _Nonnull)channelName
488 channelType:(AgoraRtmChannelType)channelType
489 data:(AgoraRtmMetadata* _Nonnull)data
490 options:(AgoraRtmMetadataOptions* _Nullable)options
491 lock:(NSString * _Nullable)lock
492 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(removeChannelMetadata(channelName:channelType:data:options:lock:completion:));
493
502 - (void) getChannelMetadata:(NSString * _Nonnull)channelName
503 channelType:(AgoraRtmChannelType)channelType
504 completion:(AgoraRtmGetMetadataBlock _Nullable)completionBlock NS_SWIFT_NAME(getChannelMetadata(channelName:channelType:completion:));
505
516 - (void) setUserMetadata:(NSString * _Nonnull)userId
517 data:(AgoraRtmMetadata* _Nonnull)data
518 options:(AgoraRtmMetadataOptions* _Nullable)options
519 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(setUserMetadata(userId:data:options:completion:));
520
530 - (void) updateUserMetadata:(NSString * _Nonnull)userId
531 data:(AgoraRtmMetadata* _Nonnull)data
532 options:(AgoraRtmMetadataOptions* _Nullable)options
533 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(updateUserMetadata(userId:data:options:completion:));
534
544 - (void) removeUserMetadata:(NSString * _Nonnull)userId
545 data:(AgoraRtmMetadata* _Nonnull)data
546 options:(AgoraRtmMetadataOptions* _Nullable)options
547 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(removeUserMetadata(userId:data:options:completion:));
548
556 - (void) getUserMetadata:(NSString * _Nonnull)userId
557 completion:(AgoraRtmGetMetadataBlock _Nullable)completionBlock NS_SWIFT_NAME(getUserMetadata(userId:completion:));
558
566 - (void) subscribeUserMetadata:(NSString * _Nonnull)userId
567 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(subscribeUserMetadata(userId:completion:));
568
576 - (void) unsubscribeUserMetadata:(NSString * _Nonnull)userId
577 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(unsubscribeUserMetadata(userId:completion:));
578 @end
579
580 __attribute__((visibility("default"))) @interface AgoraRtmLock : NSObject
581
582 - (instancetype _Nullable)init NS_UNAVAILABLE;
593 -(void) setLock:(NSString * _Nonnull)channelName
594 channelType:(AgoraRtmChannelType)channelType
595 lockName:(NSString * _Nonnull)lockName
596 ttl:(int) ttl
597 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(setLock(channelName:channelType:lockName:ttl:completion:));
598
608 -(void) removeLock:(NSString * _Nonnull)channelName
609 channelType:(AgoraRtmChannelType)channelType
610 lockName:(NSString * _Nonnull)lockName
611 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(removeLock(channelName:channelType:lockName:completion:));
612
623 -(void) acquireLock:(NSString * _Nonnull)channelName
624 channelType:(AgoraRtmChannelType)channelType
625 lockName:(NSString * _Nonnull)lockName
626 retry:(BOOL)retry
627 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(acquireLock(channelName:channelType:lockName:retry:completion:));
628
629
639 -(void) releaseLock:(NSString * _Nonnull)channelName
640 channelType:(AgoraRtmChannelType)channelType
641 lockName:(NSString * _Nonnull)lockName
642 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(releaseLock(channelName:channelType:lockName:completion:));
643
654 -(void) revokeLock:(NSString * _Nonnull)channelName
655 channelType:(AgoraRtmChannelType)channelType
656 lockName:(NSString * _Nonnull)lockName
657 userId:(NSString * _Nonnull)userId
658 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(revokeLock(channelName:channelType:lockName:userId:completion:));
659
660
669 -(void) getLocks:(NSString * _Nonnull)channelName
670 channelType:(AgoraRtmChannelType)channelType
671 completion:(AgoraRtmGetLocksBlock _Nullable)completionBlock NS_SWIFT_NAME(getLocks(channelName:channelType:completion:));
672 @end
673
674
680 __attribute__((visibility("default"))) @interface AgoraRtmPresence : NSObject
681
682 - (instancetype _Nullable)init NS_UNAVAILABLE;
683
693 -(void) whoNow:(NSString * _Nonnull)channelName
694 channelType:(AgoraRtmChannelType)channelType
695 options:(AgoraRtmPresenceOptions* _Nullable)options
696 completion:(AgoraRtmWhoNowBlock _Nullable)completionBlock NS_SWIFT_NAME(whoNow(channelName:channelType:options:completion:));
697
707 -(void) getOnlineUsers:(NSString * _Nonnull)channelName
708 channelType:(AgoraRtmChannelType)channelType
709 options:(AgoraRtmGetOnlineUsersOptions* _Nullable)options
710 completion:(AgoraRtmGetOnlineUsersBlock _Nullable)completionBlock NS_SWIFT_NAME(getOnlineUser(channelName:channelType:options:completion:));
711
719 -(void) whereNow:(NSString * _Nonnull)userId
720 completion:(AgoraRtmWhereNowBlock _Nullable)completionBlock NS_SWIFT_NAME(whereNow(userId:completion:));
721
729 -(void) getUserChannels:(NSString * _Nonnull)userId
730 completion:(AgoraRtmGetUserChannelsBlock _Nullable)completionBlock NS_SWIFT_NAME(getUserChannels(userId:completion:));
731
741 -(void) setState:(NSString * _Nonnull)channelName
742 channelType:(AgoraRtmChannelType)channelType
743 items:(NSDictionary<NSString *, NSString *> *_Nonnull)items
744 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(setState(channelName:channelType:items:completion:));
745
755 -(void) removeState:(NSString * _Nonnull)channelName
756 channelType:(AgoraRtmChannelType)channelType
757 keys:(NSArray<NSString *> * _Nonnull)keys
758 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(removeState(channelName:channelType:keys:completion:));
759
769 -(void) getState:(NSString * _Nonnull)channelName
770 channelType:(AgoraRtmChannelType)channelType
771 userId:(NSString * _Nonnull)userId
772 completion:(AgoraRtmPresenceGetStateBlock _Nullable)completionBlock NS_SWIFT_NAME(getState(channelName:channelType:userId:completion:));
773 @end
774
781 __attribute__((visibility("default"))) @interface AgoraRtmHistory : NSObject
782
783 - (instancetype _Nullable)init NS_UNAVAILABLE;
784
793 -(void) getMessages:(NSString* _Nonnull)channelName
794 channelType:(AgoraRtmChannelType)channelType
795 options:(AgoraRtmGetHistoryMessagesOptions* _Nullable)options
796 completion:(AgoraRtmGetHistoryMessagesBlock _Nullable)completionBlock NS_SWIFT_NAME(getMessages(channelName:channelType:options:completion:));
797
798 @end
AgoraRtmGetHistoryMessagesOptions
The option to query history message.
Definition: AgoraRtmObjects.h:854
AgoraRtmStorageEvent
Definition: AgoraRtmObjects.h:290
AgoraRtmGetOnlineUsersOptions
Definition: AgoraRtmObjects.h:163
AgoraRtmLinkStateEvent
Definition: AgoraRtmObjects.h:799
-[AgoraRtmClientKit getPresence]
AgoraRtmPresence *_Nullable getPresence()
-[AgoraRtmStreamChannel getChannelName]
NSString *_Nonnull getChannelName()
AgoraRtmClientDelegate-p
Definition: AgoraRtmClientKit.h:9
-[AgoraRtmStorage NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
AgoraRtmJoinChannelOption
Definition: AgoraRtmObjects.h:428
AgoraRtmPublishOptions
Definition: AgoraRtmObjects.h:55
-[AgoraRtmStreamChannel NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
-[AgoraRtmStreamChannel destroy]
AgoraRtmErrorCode destroy()
AgoraRtmMetadata
Definition: AgoraRtmObjects.h:127
AgoraRtmClientKit
Definition: AgoraRtmClientKit.h:99
-[AgoraRtmClientKit getStorage]
AgoraRtmStorage *_Nullable getStorage()
-[AgoraRtmHistory NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
-[AgoraRtmClientKit getHistory]
AgoraRtmHistory *_Nullable getHistory()
AgoraRtmTopicEvent
Definition: AgoraRtmObjects.h:224
-[AgoraRtmClientKit destroy]
AgoraRtmErrorCode destroy()
AgoraRtmTopicMessageOptions
Definition: AgoraRtmObjects.h:73
AgoraRtmClientConfig
Definition: AgoraRtmObjects.h:563
AgoraRtmClientConnectionChangeReason
AgoraRtmClientConnectionChangeReason
Definition: AgoraRtmEnumerates.h:1017
AgoraRtmLockEvent
Definition: AgoraRtmObjects.h:264
AgoraRtmJoinTopicOption
Definition: AgoraRtmObjects.h:392
AgoraRtmMessageEvent
Definition: AgoraRtmObjects.h:441
-[AgoraRtmClientKit getLock]
AgoraRtmLock *_Nullable getLock()
AgoraRtmMetadataOptions
Definition: AgoraRtmObjects.h:86
AgoraRtmStreamChannel
Definition: AgoraRtmClientKit.h:293
-[AgoraRtmPresence NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
AgoraRtmStorage
Definition: AgoraRtmClientKit.h:438
AgoraRtmErrorCode
AgoraRtmErrorCode
Definition: AgoraRtmEnumerates.h:78
-[AgoraRtmLock NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
AgoraRtmClientConnectionState
AgoraRtmClientConnectionState
Definition: AgoraRtmEnumerates.h:988
AgoraRtmObjects.h
AgoraRtmPresenceEvent
Definition: AgoraRtmObjects.h:519
AgoraRtmSubscribeOptions
Definition: AgoraRtmObjects.h:486
-[AgoraRtmClientKit NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
AgoraRtmPresenceOptions
Definition: AgoraRtmObjects.h:180
+[AgoraRtmClientKit getVersion]
NSString *_Nonnull getVersion()
AgoraRtmTopicOption
Definition: AgoraRtmObjects.h:418
AgoraRtmHistory
Definition: AgoraRtmClientKit.h:782
AgoraRtmChannelType
AgoraRtmChannelType
Definition: AgoraRtmEnumerates.h:1136
AgoraRtmPresence
Definition: AgoraRtmClientKit.h:681
AgoraRtmLock
Definition: AgoraRtmClientKit.h:581