在我的 'viewDidLoad'in
ViewController.m
中,我正在NSNotificationCenter defaultCenter
使用 ' EAAccessoryDidConnectNotification
' 和 ' EAAccessoryDidDisconnectNotification
' 注册当我的应用程序在前台处于活动状态时,我会收到通知,并在 accessoryDidConnect 中做出响应。一切正常。但是,当应用程序在后台时,我怎样才能得到这样的通知?
('EAAccessoryDidConnectNotification' and 'EAAccessoryDidDisconnectNotification')
[Code below]
非常感谢。担
(void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(accessoryDidConnect:)
name:EAAccessoryDidConnectNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(accessoryDidDisconnect:)
name:EAAccessoryDidDisconnectNotification
object:nil];
[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];
}