我一直在尝试使用来自LSApplicationWorkspace
的私有API来监控其他应用程序的状态。(只是为了好玩,无意提交给AppStore)。我尝试向{LSApplicationWorkspaceObserver
添加LSApplicationWorkspace
1}},并注册状态更改通知。
@interface MyObserver : NSObject<LSApplicationWorkspaceObserverProtocol>
- (void)applicationStateDidChange:(NSArray *)arg1;
@end
[[LSApplicationWorkspace defaultWorkspace] addObserver:[[MyObserver allocl] init]];
[[LSApplicationWorkspace defaultWorkspace] sendApplicationStateChangedNotificationsFor:@"com.apple.AppStore"];
通过选中[LSApplicationWorkspace defaultWorkspace].remoteObserver.currentObserverCount
,我可以看到MyObserver
已成功添加。但applicationStateDidChange
回调从未被调用。任何想法为何?
PS:在iOS10.2.1上运行。