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 didReceiveTokenEvent:(AgoraRtmTokenEvent * _Nonnull)event NS_SWIFT_NAME(rtmKit(_:didReceiveTokenEvent:));
78 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
79 tokenPrivilegeWillExpire:(NSString * _Nullable)channel NS_SWIFT_NAME(rtmKit(_:tokenPrivilegeWillExpire:));
80
89 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)kit
90 channel:(NSString * _Nonnull)channelName
91 connectionChangedToState:(AgoraRtmClientConnectionState)state
92 reason:(AgoraRtmClientConnectionChangeReason)reason NS_SWIFT_NAME(rtmKit(_:channel:connectionChangedToState:reason:));
93 @end
94
95 NS_ASSUME_NONNULL_BEGIN
106 __attribute__((visibility("default"))) @interface AgoraRtmClientKit : NSObject
107
108 - (instancetype _Nullable)init NS_UNAVAILABLE;
109
121 - (instancetype _Nullable)initWithConfig:(AgoraRtmClientConfig * _Nonnull)config
122 delegate:(id <AgoraRtmClientDelegate> _Nullable)delegate
123 error:(NSError**)error NS_SWIFT_NAME(init(_:delegate:));
124
132 - (void) loginByToken:(NSString* _Nullable)token
133 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(login(_:completion:));
134
141 - (void) logout:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(logout(_:));
142
149 - (AgoraRtmStorage* _Nullable)getStorage NS_SWIFT_NAME(getStorage());
150
157 - (AgoraRtmLock* _Nullable)getLock NS_SWIFT_NAME(getLock());
158
165 - (AgoraRtmPresence* _Nullable)getPresence NS_SWIFT_NAME(getPresence());
166
173 - (AgoraRtmHistory* _Nullable) getHistory NS_SWIFT_NAME(getHistory());
174
183 - (void) renewToken:(NSString* _Nonnull)token
184 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(renewToken(_:completion:));
185
194 - (void) subscribeWithChannel:(NSString* _Nonnull)channelName
195 option:(AgoraRtmSubscribeOptions* _Nullable)subscribeOption
196 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(subscribe(channelName:option:completion:));
197
205 - (void) unsubscribeWithChannel:(NSString* _Nonnull)channelName
206 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(unsubscribe(_:completion:));
216 - (void) publish:(NSString* _Nonnull)channelName
217 message:(NSString* _Nonnull)message
218 option:(AgoraRtmPublishOptions* _Nullable)publishOption
219 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(publish(channelName:message:option:completion:));
220
230 - (void) publish:(NSString* _Nonnull)channelName
231 data:(NSData* _Nonnull)data
232 option:(AgoraRtmPublishOptions* _Nullable)publishOption
233 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(publish(channelName:data:option:completion:));
234
241 - (void) addDelegate:(id <AgoraRtmClientDelegate> _Nonnull)delegate NS_SWIFT_NAME(addDelegate(_:));
242
249 - (void) removeDelegate:(id <AgoraRtmClientDelegate> _Nonnull)delegate NS_SWIFT_NAME(removeDelegate(_:));
258 - (AgoraRtmErrorCode)setParameters:(NSString* _Nonnull)parameter NS_SWIFT_NAME(setParameters(_:));
259
266 + (NSString* _Nullable)getErrorReason:(AgoraRtmErrorCode)errorCode NS_SWIFT_NAME(getErrorReason(_:));
272 + (NSString * _Nonnull)getVersion NS_SWIFT_NAME(getVersion());
273
274
284 - (AgoraRtmStreamChannel * _Nullable)createStreamChannel:(NSString * _Nonnull)channelName
285 error:(NSError**)error NS_SWIFT_NAME(createStreamChannel(_:));
286
287
295 - (AgoraRtmErrorCode)destroy NS_SWIFT_NAME(destroy());
296 @end
297
298 NS_ASSUME_NONNULL_END
299
300 __attribute__((visibility("default"))) @interface AgoraRtmStreamChannel : NSObject
301
302 - (instancetype _Nullable)init NS_UNAVAILABLE;
310 - (void)joinWithOption:(AgoraRtmJoinChannelOption * _Nonnull)option
311 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(join(_:completion:));
312
319 - (void)leave:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(leave(_:));
320
329 - (void)renewToken:(NSString* _Nonnull)token
330 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(renewToken(_:completion:));
331
340 - (void) joinTopic:(NSString * _Nonnull)topic
341 option:(AgoraRtmJoinTopicOption * _Nullable)option
342 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(joinTopic(_:option:completion:));
343
351 - (void) leaveTopic:(NSString * _Nonnull)topic
352 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(leaveTopic(_:completion:));
353
362 - (void) subscribeTopic:(NSString * _Nonnull)topic
363 option:(AgoraRtmTopicOption * _Nullable)option
364 completion:(AgoraRtmTopicSubscriptionBlock _Nullable)completionBlock NS_SWIFT_NAME(subscribeTopic(_:option:completion:));
365
366
375 - (void) unsubscribeTopic:(NSString * _Nonnull)topic
376 option:(AgoraRtmTopicOption * _Nullable)option
377 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(unsubscribeTopic(_:option:completion:));
378
388 - (void) publishTopicMessage:(NSString * _Nonnull)topic
389 message:(NSString * _Nonnull)message
390 option:(AgoraRtmTopicMessageOptions * _Nullable)options
391 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(publishTopicMessage(topic:message:option:completion:));
392
393
403 - (void) publishTopicMessage:(NSString * _Nonnull)topic
404 data:(NSData * _Nonnull)data
405 option:(AgoraRtmTopicMessageOptions * _Nullable)options
406 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(publishTopicMessage(topic:data:option:completion:));
414 - (void) getSubscribedUserList:(NSString* _Nonnull)topic
415 completion:(AgoraRtmGetTopicSubscribedUsersBlock _Nullable)completionBlock NS_SWIFT_NAME(getSubscribedUserList(_:completion:));
416
422 - (NSString * _Nonnull)getChannelName NS_SWIFT_NAME(getChannelName());
423
432 - (AgoraRtmErrorCode)setParameters:(NSString* _Nonnull)parameters NS_SWIFT_NAME(setParameters(_:));
433
441 - (AgoraRtmErrorCode)destroy;
442
443 @end
444
445 __attribute__((visibility("default"))) @interface AgoraRtmStorage : NSObject
446
447 - (instancetype _Nullable)init NS_UNAVAILABLE;
459 - (void) setChannelMetadata:(NSString * _Nonnull)channelName
460 channelType:(AgoraRtmChannelType)channelType
461 data:(AgoraRtmMetadata* _Nonnull)data
462 options:(AgoraRtmMetadataOptions* _Nullable)options
463 lock:(NSString * _Nullable)lock
464 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(setChannelMetadata(channelName:channelType:data:options:lock:completion:));
465
477 - (void) updateChannelMetadata:(NSString * _Nonnull)channelName
478 channelType:(AgoraRtmChannelType)channelType
479 data:(AgoraRtmMetadata* _Nonnull)data
480 options:(AgoraRtmMetadataOptions* _Nullable)options
481 lock:(NSString * _Nullable)lock
482 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(updateChannelMetadata(channelName:channelType:data:options:lock:completion:));
483
495 - (void) removeChannelMetadata:(NSString * _Nonnull)channelName
496 channelType:(AgoraRtmChannelType)channelType
497 data:(AgoraRtmMetadata* _Nonnull)data
498 options:(AgoraRtmMetadataOptions* _Nullable)options
499 lock:(NSString * _Nullable)lock
500 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(removeChannelMetadata(channelName:channelType:data:options:lock:completion:));
501
510 - (void) getChannelMetadata:(NSString * _Nonnull)channelName
511 channelType:(AgoraRtmChannelType)channelType
512 completion:(AgoraRtmGetMetadataBlock _Nullable)completionBlock NS_SWIFT_NAME(getChannelMetadata(channelName:channelType:completion:));
513
524 - (void) setUserMetadata:(NSString * _Nonnull)userId
525 data:(AgoraRtmMetadata* _Nonnull)data
526 options:(AgoraRtmMetadataOptions* _Nullable)options
527 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(setUserMetadata(userId:data:options:completion:));
528
538 - (void) updateUserMetadata:(NSString * _Nonnull)userId
539 data:(AgoraRtmMetadata* _Nonnull)data
540 options:(AgoraRtmMetadataOptions* _Nullable)options
541 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(updateUserMetadata(userId:data:options:completion:));
542
552 - (void) removeUserMetadata:(NSString * _Nonnull)userId
553 data:(AgoraRtmMetadata* _Nonnull)data
554 options:(AgoraRtmMetadataOptions* _Nullable)options
555 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(removeUserMetadata(userId:data:options:completion:));
556
564 - (void) getUserMetadata:(NSString * _Nonnull)userId
565 completion:(AgoraRtmGetMetadataBlock _Nullable)completionBlock NS_SWIFT_NAME(getUserMetadata(userId:completion:));
566
574 - (void) subscribeUserMetadata:(NSString * _Nonnull)userId
575 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(subscribeUserMetadata(userId:completion:));
576
584 - (void) unsubscribeUserMetadata:(NSString * _Nonnull)userId
585 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(unsubscribeUserMetadata(userId:completion:));
586 @end
587
588 __attribute__((visibility("default"))) @interface AgoraRtmLock : NSObject
589
590 - (instancetype _Nullable)init NS_UNAVAILABLE;
601 -(void) setLock:(NSString * _Nonnull)channelName
602 channelType:(AgoraRtmChannelType)channelType
603 lockName:(NSString * _Nonnull)lockName
604 ttl:(int) ttl
605 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(setLock(channelName:channelType:lockName:ttl:completion:));
606
616 -(void) removeLock:(NSString * _Nonnull)channelName
617 channelType:(AgoraRtmChannelType)channelType
618 lockName:(NSString * _Nonnull)lockName
619 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(removeLock(channelName:channelType:lockName:completion:));
620
631 -(void) acquireLock:(NSString * _Nonnull)channelName
632 channelType:(AgoraRtmChannelType)channelType
633 lockName:(NSString * _Nonnull)lockName
634 retry:(BOOL)retry
635 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(acquireLock(channelName:channelType:lockName:retry:completion:));
636
637
647 -(void) releaseLock:(NSString * _Nonnull)channelName
648 channelType:(AgoraRtmChannelType)channelType
649 lockName:(NSString * _Nonnull)lockName
650 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(releaseLock(channelName:channelType:lockName:completion:));
651
662 -(void) revokeLock:(NSString * _Nonnull)channelName
663 channelType:(AgoraRtmChannelType)channelType
664 lockName:(NSString * _Nonnull)lockName
665 userId:(NSString * _Nonnull)userId
666 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(revokeLock(channelName:channelType:lockName:userId:completion:));
667
668
677 -(void) getLocks:(NSString * _Nonnull)channelName
678 channelType:(AgoraRtmChannelType)channelType
679 completion:(AgoraRtmGetLocksBlock _Nullable)completionBlock NS_SWIFT_NAME(getLocks(channelName:channelType:completion:));
680 @end
681
682
688 __attribute__((visibility("default"))) @interface AgoraRtmPresence : NSObject
689
690 - (instancetype _Nullable)init NS_UNAVAILABLE;
691
701 -(void) whoNow:(NSString * _Nonnull)channelName
702 channelType:(AgoraRtmChannelType)channelType
703 options:(AgoraRtmPresenceOptions* _Nullable)options
704 completion:(AgoraRtmWhoNowBlock _Nullable)completionBlock NS_SWIFT_NAME(whoNow(channelName:channelType:options:completion:));
705
715 -(void) getOnlineUsers:(NSString * _Nonnull)channelName
716 channelType:(AgoraRtmChannelType)channelType
717 options:(AgoraRtmGetOnlineUsersOptions* _Nullable)options
718 completion:(AgoraRtmGetOnlineUsersBlock _Nullable)completionBlock NS_SWIFT_NAME(getOnlineUser(channelName:channelType:options:completion:));
719
727 -(void) whereNow:(NSString * _Nonnull)userId
728 completion:(AgoraRtmWhereNowBlock _Nullable)completionBlock NS_SWIFT_NAME(whereNow(userId:completion:));
729
737 -(void) getUserChannels:(NSString * _Nonnull)userId
738 completion:(AgoraRtmGetUserChannelsBlock _Nullable)completionBlock NS_SWIFT_NAME(getUserChannels(userId:completion:));
739
749 -(void) setState:(NSString * _Nonnull)channelName
750 channelType:(AgoraRtmChannelType)channelType
751 items:(NSDictionary<NSString *, NSString *> *_Nonnull)items
752 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(setState(channelName:channelType:items:completion:));
753
763 -(void) removeState:(NSString * _Nonnull)channelName
764 channelType:(AgoraRtmChannelType)channelType
765 keys:(NSArray<NSString *> * _Nonnull)keys
766 completion:(AgoraRtmOperationBlock _Nullable)completionBlock NS_SWIFT_NAME(removeState(channelName:channelType:keys:completion:));
767
777 -(void) getState:(NSString * _Nonnull)channelName
778 channelType:(AgoraRtmChannelType)channelType
779 userId:(NSString * _Nonnull)userId
780 completion:(AgoraRtmPresenceGetStateBlock _Nullable)completionBlock NS_SWIFT_NAME(getState(channelName:channelType:userId:completion:));
781 @end
782
789 __attribute__((visibility("default"))) @interface AgoraRtmHistory : NSObject
790
791 - (instancetype _Nullable)init NS_UNAVAILABLE;
792
801 -(void) getMessages:(NSString* _Nonnull)channelName
802 channelType:(AgoraRtmChannelType)channelType
803 options:(AgoraRtmGetHistoryMessagesOptions* _Nullable)options
804 completion:(AgoraRtmGetHistoryMessagesBlock _Nullable)completionBlock NS_SWIFT_NAME(getMessages(channelName:channelType:options:completion:));
805
806 @end
AgoraRtmGetHistoryMessagesOptions
The option to query history message.
Definition: AgoraRtmObjects.h:898
AgoraRtmStorageEvent
Definition: AgoraRtmObjects.h:292
AgoraRtmGetOnlineUsersOptions
Definition: AgoraRtmObjects.h:165
AgoraRtmLinkStateEvent
Definition: AgoraRtmObjects.h:843
-[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:430
AgoraRtmPublishOptions
Definition: AgoraRtmObjects.h:57
-[AgoraRtmStreamChannel NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
-[AgoraRtmStreamChannel destroy]
AgoraRtmErrorCode destroy()
AgoraRtmMetadata
Definition: AgoraRtmObjects.h:129
AgoraRtmClientKit
Definition: AgoraRtmClientKit.h:107
-[AgoraRtmClientKit getStorage]
AgoraRtmStorage *_Nullable getStorage()
-[AgoraRtmHistory NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
-[AgoraRtmClientKit getHistory]
AgoraRtmHistory *_Nullable getHistory()
AgoraRtmTopicEvent
Definition: AgoraRtmObjects.h:226
-[AgoraRtmClientKit destroy]
AgoraRtmErrorCode destroy()
AgoraRtmTopicMessageOptions
Definition: AgoraRtmObjects.h:75
AgoraRtmClientConfig
Definition: AgoraRtmObjects.h:595
AgoraRtmClientConnectionChangeReason
AgoraRtmClientConnectionChangeReason
Definition: AgoraRtmEnumerates.h:1047
AgoraRtmLockEvent
Definition: AgoraRtmObjects.h:266
AgoraRtmJoinTopicOption
Definition: AgoraRtmObjects.h:394
AgoraRtmMessageEvent
Definition: AgoraRtmObjects.h:443
-[AgoraRtmClientKit getLock]
AgoraRtmLock *_Nullable getLock()
AgoraRtmMetadataOptions
Definition: AgoraRtmObjects.h:88
AgoraRtmStreamChannel
Definition: AgoraRtmClientKit.h:301
-[AgoraRtmPresence NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
AgoraRtmTokenEvent
Definition: AgoraRtmObjects.h:562
AgoraRtmStorage
Definition: AgoraRtmClientKit.h:446
AgoraRtmErrorCode
AgoraRtmErrorCode
Definition: AgoraRtmEnumerates.h:92
-[AgoraRtmLock NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
AgoraRtmClientConnectionState
AgoraRtmClientConnectionState
Definition: AgoraRtmEnumerates.h:1018
AgoraRtmObjects.h
AgoraRtmPresenceEvent
Definition: AgoraRtmObjects.h:521
AgoraRtmSubscribeOptions
Definition: AgoraRtmObjects.h:488
-[AgoraRtmClientKit NS_UNAVAILABLE]
instancetype _Nullable NS_UNAVAILABLE()
AgoraRtmPresenceOptions
Definition: AgoraRtmObjects.h:182
+[AgoraRtmClientKit getVersion]
NSString *_Nonnull getVersion()
AgoraRtmTopicOption
Definition: AgoraRtmObjects.h:420
AgoraRtmHistory
Definition: AgoraRtmClientKit.h:790
AgoraRtmChannelType
AgoraRtmChannelType
Definition: AgoraRtmEnumerates.h:1166
AgoraRtmPresence
Definition: AgoraRtmClientKit.h:689
AgoraRtmLock
Definition: AgoraRtmClientKit.h:589