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

DarwinNotificationCenter.m 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright @ 2021-present 8x8, Inc.
  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 "DarwinNotificationCenter.h"
  17. NSNotificationName const kBroadcastStartedNotification = @"iOS_BroadcastStarted";
  18. NSNotificationName const kBroadcastStoppedNotification = @"iOS_BroadcastStopped";
  19. @implementation DarwinNotificationCenter {
  20. CFNotificationCenterRef _notificationCenter;
  21. }
  22. + (instancetype)sharedInstance {
  23. static DarwinNotificationCenter *sharedInstance = nil;
  24. static dispatch_once_t onceToken;
  25. dispatch_once(&onceToken, ^{
  26. sharedInstance = [[self alloc] init];
  27. });
  28. return sharedInstance;
  29. }
  30. - (instancetype)init {
  31. self = [super init];
  32. if (self) {
  33. _notificationCenter = CFNotificationCenterGetDarwinNotifyCenter();
  34. }
  35. return self;
  36. }
  37. - (void)postNotificationWithName:(NSString*)name {
  38. CFNotificationCenterPostNotification(_notificationCenter, (__bridge CFStringRef)name, NULL, NULL, true);
  39. }
  40. @end