Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ViewController.m 3.6KB

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