2017-05-08 15:21:30 +00:00
|
|
|
/*
|
2019-01-23 12:48:34 +00:00
|
|
|
* Copyright @ 2018-present 8x8, Inc.
|
|
|
|
* Copyright @ 2017-2018 Atlassian Pty Ltd
|
2017-05-08 15:21:30 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2018-10-18 13:54:26 +00:00
|
|
|
#import <Availability.h>
|
2019-01-23 12:48:34 +00:00
|
|
|
|
|
|
|
@import CoreSpotlight;
|
|
|
|
@import MobileCoreServices;
|
|
|
|
@import Intents; // Needed for NSUserActivity suggestedInvocationPhrase
|
2018-10-18 13:54:26 +00:00
|
|
|
|
2019-02-08 09:40:37 +00:00
|
|
|
@import JitsiMeet;
|
|
|
|
|
2018-10-18 13:54:26 +00:00
|
|
|
#import "Types.h"
|
2017-05-08 15:21:30 +00:00
|
|
|
#import "ViewController.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation ViewController
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
2017-06-06 22:43:51 +00:00
|
|
|
[super viewDidLoad];
|
2017-05-08 15:21:30 +00:00
|
|
|
|
2017-06-06 22:43:51 +00:00
|
|
|
JitsiMeetView *view = (JitsiMeetView *) self.view;
|
2018-10-18 13:54:26 +00:00
|
|
|
view.delegate = self;
|
2017-05-08 15:21:30 +00:00
|
|
|
|
2019-02-08 09:40:37 +00:00
|
|
|
[view join:[[JitsiMeet sharedInstance] getInitialConferenceOptions]];
|
2017-05-08 15:21:30 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 03:39:20 +00:00
|
|
|
// JitsiMeetViewDelegate
|
|
|
|
|
2018-05-21 00:01:59 +00:00
|
|
|
- (void)_onJitsiMeetViewDelegateEvent:(NSString *)name
|
|
|
|
withData:(NSDictionary *)data {
|
2017-09-06 17:57:33 +00:00
|
|
|
NSLog(
|
|
|
|
@"[%s:%d] JitsiMeetViewDelegate %@ %@",
|
|
|
|
__FILE__, __LINE__, name, data);
|
2018-05-17 11:38:59 +00:00
|
|
|
|
2019-05-22 18:53:13 +00:00
|
|
|
#if DEBUG
|
2018-05-21 00:01:59 +00:00
|
|
|
NSAssert(
|
|
|
|
[NSThread isMainThread],
|
|
|
|
@"JitsiMeetViewDelegate %@ method invoked on a non-main thread",
|
|
|
|
name);
|
2018-10-18 13:54:26 +00:00
|
|
|
#endif
|
2017-09-06 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)conferenceJoined:(NSDictionary *)data {
|
2018-05-21 00:01:59 +00:00
|
|
|
[self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_JOINED" withData:data];
|
2018-10-18 13:54:26 +00:00
|
|
|
|
|
|
|
// Register a NSUserActivity for this conference so it can be invoked as a
|
|
|
|
// Siri shortcut. This is only supported in iOS >= 12.
|
|
|
|
#ifdef __IPHONE_12_0
|
|
|
|
if (@available(iOS 12.0, *)) {
|
|
|
|
NSUserActivity *userActivity
|
|
|
|
= [[NSUserActivity alloc] initWithActivityType:JitsiMeetConferenceActivityType];
|
|
|
|
|
|
|
|
NSString *urlStr = data[@"url"];
|
|
|
|
NSURL *url = [NSURL URLWithString:urlStr];
|
|
|
|
NSString *conference = [url.pathComponents lastObject];
|
|
|
|
|
|
|
|
userActivity.title = [NSString stringWithFormat:@"Join %@", conference];
|
|
|
|
userActivity.suggestedInvocationPhrase = @"Join my Jitsi meeting";
|
|
|
|
userActivity.userInfo = @{@"url": urlStr};
|
|
|
|
[userActivity setEligibleForSearch:YES];
|
|
|
|
[userActivity setEligibleForPrediction:YES];
|
|
|
|
[userActivity setPersistentIdentifier:urlStr];
|
|
|
|
|
|
|
|
// Subtitle
|
|
|
|
CSSearchableItemAttributeSet *attributes
|
|
|
|
= [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeItem];
|
|
|
|
attributes.contentDescription = urlStr;
|
|
|
|
userActivity.contentAttributeSet = attributes;
|
|
|
|
|
|
|
|
self.userActivity = userActivity;
|
|
|
|
[userActivity becomeCurrent];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 12:07:48 +00:00
|
|
|
- (void)conferenceTerminated:(NSDictionary *)data {
|
|
|
|
[self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_TERMINATED" withData:data];
|
2017-09-06 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)conferenceWillJoin:(NSDictionary *)data {
|
2018-05-21 00:01:59 +00:00
|
|
|
[self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_WILL_JOIN" withData:data];
|
2017-09-06 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
2017-05-08 15:21:30 +00:00
|
|
|
@end
|