尝试使用私有api监控应用运行状态问题

在阅读LSApplicationWorkspace的api时发现有一个LSApplicationWorkspaceObserver的类,可监听applicationStateDidChange通知,所以尝试自己添加一个observer来监控应用的运行状态,大致调用代码如下:

 @interface MyObserver : NSObject<LSApplicationWorkspaceObserverProtocol>
    - (void)applicationStateDidChange:(NSArray *)arg1;
    @end 
    [[LSApplicationWorkspace defaultWorkspace] addObserver:[[MyObserver allocl] init]];
    [[LSApplicationWorkspace defaultWorkspace] sendApplicationStateChangedNotificationsFor:@"com.tencent.xin"];

通过打印[LSApplicationWorkspace defaultWorkspace].remoteObserver.currentObserverCount可以确认MyObserver已经添加成功,但是始终无法收到回调,求解。

PS:代码调用使用RuntimeInvoker,运行环境10.2.1

应该是需要权限

什么权限,求指点

iOS Entitlements

如果你找到答案的话,请写一下具体原因,因为我也想知道:grinning:

需要加什么key?