Why can't I receive a notification sent from Camera Extension(Swift) to an observer application (obj-c++)

22 views Asked by At

Both the extension and the receiving application are in the same app group.

I can't find the issue. It doesn't seem to be a problem with entitlements. Maybe an issue with the string formatting/conversion? Maybe I am not allowed to send distributed center notifications from the camera extension?

I am sending the notification from the notifyChangeInUsage method in a working camera extension, calling:

class CameraDeviceSource: NSObject, CMIOExtensionDeviceSource {
 //
 // ...
 //
 func notifyChangeInUsage() {
      os_log("Notifying the virtual camera change in usage", log: cdsLog, type: .info) // this is logged
      DistributedNotificationCenter.default().postNotificationName(NSNotification.Name("CamUsageChanged"), object: nil, userInfo: nil, deliverImmediately: true)
  }
}

And receiving it in the other end, subscribing with

std::string notification = "CamUsageChanged"
[mObserverClassInstance subscribe:@(notification.c_str())];

where subscribe is the following method, which is tested to be working.


- (void)subscribe:(NSString *)notification {
  [[NSDistributedNotificationCenter defaultCenter]
             addObserver:self
                selector:@selector(callCallback:)
                    name:notification
                  object:nil
      suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
}
0

There are 0 answers