選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ViewController.m 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright @ 2018-present 8x8, Inc.
  3. * Copyright @ 2017-2018 Atlassian Pty Ltd
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #import <Availability.h>
  18. @import CoreSpotlight;
  19. @import MobileCoreServices;
  20. @import Intents; // Needed for NSUserActivity suggestedInvocationPhrase
  21. @import JitsiMeet;
  22. #import "Types.h"
  23. #import "ViewController.h"
  24. @implementation ViewController
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. JitsiMeetView *view = (JitsiMeetView *) self.view;
  28. view.delegate = self;
  29. [view join:[[JitsiMeet sharedInstance] getInitialConferenceOptions]];
  30. }
  31. // JitsiMeetViewDelegate
  32. - (void)_onJitsiMeetViewDelegateEvent:(NSString *)name
  33. withData:(NSDictionary *)data {
  34. NSLog(
  35. @"[%s:%d] JitsiMeetViewDelegate %@ %@",
  36. __FILE__, __LINE__, name, data);
  37. #if DEBUG
  38. NSAssert(
  39. [NSThread isMainThread],
  40. @"JitsiMeetViewDelegate %@ method invoked on a non-main thread",
  41. name);
  42. #endif
  43. }
  44. - (void)conferenceJoined:(NSDictionary *)data {
  45. [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_JOINED" withData:data];
  46. // Register a NSUserActivity for this conference so it can be invoked as a
  47. // Siri shortcut. This is only supported in iOS >= 12.
  48. #ifdef __IPHONE_12_0
  49. if (@available(iOS 12.0, *)) {
  50. NSUserActivity *userActivity
  51. = [[NSUserActivity alloc] initWithActivityType:JitsiMeetConferenceActivityType];
  52. NSString *urlStr = data[@"url"];
  53. NSURL *url = [NSURL URLWithString:urlStr];
  54. NSString *conference = [url.pathComponents lastObject];
  55. userActivity.title = [NSString stringWithFormat:@"Join %@", conference];
  56. userActivity.suggestedInvocationPhrase = @"Join my Jitsi meeting";
  57. userActivity.userInfo = @{@"url": urlStr};
  58. [userActivity setEligibleForSearch:YES];
  59. [userActivity setEligibleForPrediction:YES];
  60. [userActivity setPersistentIdentifier:urlStr];
  61. // Subtitle
  62. CSSearchableItemAttributeSet *attributes
  63. = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeItem];
  64. attributes.contentDescription = urlStr;
  65. userActivity.contentAttributeSet = attributes;
  66. self.userActivity = userActivity;
  67. [userActivity becomeCurrent];
  68. }
  69. #endif
  70. }
  71. - (void)conferenceTerminated:(NSDictionary *)data {
  72. [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_TERMINATED" withData:data];
  73. }
  74. - (void)conferenceWillJoin:(NSDictionary *)data {
  75. [self _onJitsiMeetViewDelegateEvent:@"CONFERENCE_WILL_JOIN" withData:data];
  76. }
  77. #if 0
  78. - (void)enterPictureInPicture:(NSDictionary *)data {
  79. [self _onJitsiMeetViewDelegateEvent:@"ENTER_PICTURE_IN_PICTURE" withData:data];
  80. }
  81. #endif
  82. @end