forked from skrafft/react-native-jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RNJitsiMeetViewManager.m
94 lines (77 loc) · 2.41 KB
/
RNJitsiMeetViewManager.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#import "RNJitsiMeetViewManager.h"
#import "RNJitsiMeetView.h"
@implementation RNJitsiMeetViewManager{
RNJitsiMeetView *jitsiMeetView;
}
RCT_EXPORT_MODULE(RNJitsiMeetView)
RCT_EXPORT_VIEW_PROPERTY(onConferenceJoined, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onConferenceTerminated, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onConferenceWillJoin, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onEnteredPip, RCTBubblingEventBlock)
- (UIView *)view
{
jitsiMeetView = [[RNJitsiMeetView alloc] init];
jitsiMeetView.delegate = self;
return jitsiMeetView;
}
RCT_EXPORT_METHOD(initialize)
{
RCTLogInfo(@"Initialize is deprecated in v2");
}
RCT_EXPORT_METHOD(call:(NSString *)urlString)
{
RCTLogInfo(@"Load URL %@", urlString);
dispatch_sync(dispatch_get_main_queue(), ^{
JitsiMeetConferenceOptions *options = [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
builder.room = urlString;
}];
[jitsiMeetView join:options];
});
}
RCT_EXPORT_METHOD(audioCall:(NSString *)urlString)
{
RCTLogInfo(@"Load Audio only URL %@", urlString);
dispatch_sync(dispatch_get_main_queue(), ^{
JitsiMeetConferenceOptions *options = [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
builder.room = urlString;
builder.audioOnly = YES;
}];
[jitsiMeetView join:options];
});
}
RCT_EXPORT_METHOD(endCall)
{
dispatch_sync(dispatch_get_main_queue(), ^{
[jitsiMeetView leave];
});
}
#pragma mark JitsiMeetViewDelegate
- (void)conferenceJoined:(NSDictionary *)data {
RCTLogInfo(@"Conference joined");
if (!jitsiMeetView.onConferenceJoined) {
return;
}
jitsiMeetView.onConferenceJoined(data);
}
- (void)conferenceTerminated:(NSDictionary *)data {
RCTLogInfo(@"Conference terminated");
if (!jitsiMeetView.onConferenceTerminated) {
return;
}
jitsiMeetView.onConferenceTerminated(data);
}
- (void)conferenceWillJoin:(NSDictionary *)data {
RCTLogInfo(@"Conference will join");
if (!jitsiMeetView.onConferenceWillJoin) {
return;
}
jitsiMeetView.onConferenceWillJoin(data);
}
- (void)enterPictureInPicture:(NSDictionary *)data {
RCTLogInfo(@"Enter Picture in Picture");
if (!jitsiMeetView.onEnteredPip) {
return;
}
jitsiMeetView.onEnteredPip(data);
}
@end