mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Update JistiViewController to use new JitsiMeet SDK API
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
#import <JitsiMeet/JitsiMeet.h>
|
||||
|
||||
#import "WidgetManager.h"
|
||||
|
||||
@protocol JitsiViewControllerDelegate;
|
||||
@@ -28,7 +26,7 @@
|
||||
|
||||
https://github.com/jitsi/jitsi-meet/tree/master/ios
|
||||
*/
|
||||
@interface JitsiViewController : MXKViewController <JitsiMeetViewDelegate>
|
||||
@interface JitsiViewController : MXKViewController
|
||||
|
||||
/**
|
||||
Returns the `UINib` object initialized for a `JitsiViewController`.
|
||||
@@ -75,12 +73,6 @@
|
||||
*/
|
||||
@property (nonatomic) id<JitsiViewControllerDelegate> delegate;
|
||||
|
||||
#pragma mark - Xib attributes
|
||||
|
||||
// The jitsi-meet SDK view
|
||||
@property (weak, nonatomic) IBOutlet JitsiMeetView *jitsiMeetView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *backToAppButton;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@@ -15,15 +15,17 @@
|
||||
*/
|
||||
|
||||
#import "JitsiViewController.h"
|
||||
@import JitsiMeet;
|
||||
|
||||
static const NSString *kJitsiServerUrl = @"https://jitsi.riot.im/";
|
||||
static const NSString *kJitsiDataErrorKey = @"error";
|
||||
|
||||
@interface JitsiViewController ()
|
||||
{
|
||||
NSString *jitsiUrl;
|
||||
@interface JitsiViewController () <JitsiMeetViewDelegate>
|
||||
|
||||
BOOL video;
|
||||
}
|
||||
// The jitsi-meet SDK view
|
||||
@property (nonatomic, weak) IBOutlet JitsiMeetView *jitsiMeetView;
|
||||
|
||||
@property (nonatomic, strong) NSString *conferenceId;
|
||||
@property (nonatomic) BOOL startWithVideo;
|
||||
|
||||
@end
|
||||
|
||||
@@ -44,14 +46,41 @@ static const NSString *kJitsiServerUrl = @"https://jitsi.riot.im/";
|
||||
return jitsiViewController;
|
||||
}
|
||||
|
||||
#pragma mark - Life cycle
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.jitsiMeetView.delegate = self;
|
||||
|
||||
[self joinConference];
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
#pragma mark - Public
|
||||
|
||||
- (void)openWidget:(Widget*)widget withVideo:(BOOL)aVideo
|
||||
success:(void (^)(void))success
|
||||
failure:(void (^)(NSError *error))failure
|
||||
{
|
||||
video = aVideo;
|
||||
self.startWithVideo = aVideo;
|
||||
_widget = widget;
|
||||
|
||||
MXWeakify(self);
|
||||
|
||||
[_widget widgetUrl:^(NSString * _Nonnull widgetUrl) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
// Extract the jitsi conference id from the widget url
|
||||
NSString *confId;
|
||||
@@ -69,15 +98,11 @@ static const NSString *kJitsiServerUrl = @"https://jitsi.riot.im/";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// And build from it the url to use in jitsi-meet sdk
|
||||
if (confId)
|
||||
{
|
||||
jitsiUrl = [NSString stringWithFormat:@"%@%@", kJitsiServerUrl, confId];
|
||||
}
|
||||
}
|
||||
|
||||
self.conferenceId = confId;
|
||||
|
||||
if (jitsiUrl)
|
||||
if (confId)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
@@ -107,71 +132,72 @@ static const NSString *kJitsiServerUrl = @"https://jitsi.riot.im/";
|
||||
|
||||
- (void)hangup
|
||||
{
|
||||
jitsiUrl = nil;
|
||||
[self.jitsiMeetView leave];
|
||||
}
|
||||
|
||||
// It would have been nicer to ask JitsiMeetView but there is no api.
|
||||
// Dismissing the view controller and releasing it does the job for the moment
|
||||
if (_delegate)
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)joinConference
|
||||
{
|
||||
[self joinConferenceWithId:self.conferenceId];
|
||||
}
|
||||
|
||||
- (void)joinConferenceWithId:(NSString*)conferenceId
|
||||
{
|
||||
if (conferenceId)
|
||||
{
|
||||
[_delegate jitsiViewController:self dismissViewJitsiController:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.jitsiMeetView.delegate = self;
|
||||
|
||||
// Pass the URL to jitsi-meet sdk
|
||||
[self.jitsiMeetView loadURLObject: @{
|
||||
@"url": jitsiUrl,
|
||||
@"configOverwrite": @{
|
||||
@"startWithVideoMuted": @(!video)
|
||||
}
|
||||
}];
|
||||
|
||||
// TODO: Set up user info but it is not yet available in the jitsi-meet iOS SDK
|
||||
// See https://github.com/jitsi/jitsi-meet/issues/1880
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (IBAction)onBackToAppButtonPressed:(id)sender
|
||||
{
|
||||
if (_delegate)
|
||||
{
|
||||
[_delegate jitsiViewController:self goBackToApp:nil];
|
||||
// TODO: Set up user info but it is not yet available in the jitsi-meet iOS SDK
|
||||
// See https://github.com/jitsi/jitsi-meet/issues/1880
|
||||
|
||||
JitsiMeetConferenceOptions *jitsiMeetConferenceOptions = [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder * _Nonnull jitsiMeetConferenceOptionsBuilder) {
|
||||
jitsiMeetConferenceOptionsBuilder.room = conferenceId;
|
||||
jitsiMeetConferenceOptionsBuilder.videoMuted = !self.startWithVideo;
|
||||
}];
|
||||
|
||||
[self.jitsiMeetView join:jitsiMeetConferenceOptions];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - JitsiMeetViewDelegate
|
||||
|
||||
- (void)conferenceFailed:(NSDictionary *)data
|
||||
- (void)conferenceWillJoin:(NSDictionary *)data
|
||||
{
|
||||
NSLog(@"[JitsiViewController] conferenceFailed - data: %@", data);
|
||||
}
|
||||
|
||||
- (void)conferenceLeft:(NSDictionary *)data
|
||||
- (void)conferenceJoined:(NSDictionary *)data
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
// The conference is over. Let the delegate close this view controller.
|
||||
if (_delegate)
|
||||
{
|
||||
[_delegate jitsiViewController:self dismissViewJitsiController:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do it ourself
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)conferenceTerminated:(NSDictionary *)data
|
||||
{
|
||||
if (data[kJitsiDataErrorKey] != nil)
|
||||
{
|
||||
NSLog(@"[JitsiViewController] conferenceFailed - data: %@", data);
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
// The conference is over. Let the delegate close this view controller.
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate jitsiViewController:self dismissViewJitsiController:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do it ourself
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)enterPictureInPicture:(NSDictionary *)data
|
||||
{
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate jitsiViewController:self goBackToApp:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.70"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="JitsiViewController">
|
||||
<connections>
|
||||
<outlet property="backToAppButton" destination="8tr-Cb-ue8" id="aUj-co-7JA"/>
|
||||
<outlet property="jitsiMeetView" destination="7hL-Cs-mak" id="7kR-Te-Klw"/>
|
||||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
|
||||
</connections>
|
||||
@@ -25,41 +24,14 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8tr-Cb-ue8">
|
||||
<rect key="frame" x="10" y="5" width="44" height="44"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="CallVCBackToAppButton"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="3id-6Q-PUF"/>
|
||||
<constraint firstAttribute="width" constant="44" id="JGj-Jz-SbU"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="13"/>
|
||||
<color key="tintColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<inset key="titleEdgeInsets" minX="-69" minY="61" maxX="0.0" maxY="0.0"/>
|
||||
<state key="normal" image="back_icon">
|
||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
<state key="highlighted">
|
||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onBackToAppButtonPressed:" destination="-1" eventType="touchUpInside" id="2wo-nB-Rwd"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="7hL-Cs-mak" secondAttribute="trailing" id="8eH-2r-pjD"/>
|
||||
<constraint firstAttribute="bottom" secondItem="7hL-Cs-mak" secondAttribute="bottom" id="BAo-6X-ovC"/>
|
||||
<constraint firstItem="8tr-Cb-ue8" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="5" id="FPS-wy-gK6"/>
|
||||
<constraint firstItem="8tr-Cb-ue8" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="10" id="Xca-R4-1cu"/>
|
||||
<constraint firstItem="7hL-Cs-mak" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="s46-Fx-tT8"/>
|
||||
<constraint firstItem="7hL-Cs-mak" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="x3v-Xl-cKi"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="back_icon" width="13" height="23"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
Reference in New Issue
Block a user