2013年12月4日水曜日
ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213.3/EASession.m:-[EASession dealloc]
発生しているエラー
2013-08-28 14:04:20.879 UNITE-POS[365:907] ERROR - opening session failed
2013-08-28 14:04:20.881 UNITE-POS[365:907] ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213.3/EASession.m:-[EASession dealloc]
- 137 unable to close session for _accessory=0x20887b40 and sessionID=65536
2013-12-03 11:51:05.935 UNITE-POS[1575:60b] ERROR - opening session failed
2013-12-03 11:51:05.936 UNITE-POS[1575:60b] ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-242/EASession.m:-[EASession dealloc]
- 139 unable to close session for _accessory=0x15d9dea0 and sessionID=65536
参考にしたマニュアル、サンプル
https://developer.apple.com/library/ios/samplecode/EADemo/Introduction/Intro.html
修正例
[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_accessoryDidConnect:)
name:EAAccessoryDidConnectNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_accessoryDidDisconnect:)
name:EAAccessoryDidDisconnectNotification
object:nil];
- (void)_accessoryDidDisconnect:(NSNotification *)notification
{
[_service closeSession];
NSLog(@"▼ScannerPlugin.m DidDisconnect -> close");
CDVPluginResult *result;
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"_accessoryDidDisconnect"];
[self writeJavascript:[result toSuccessCallbackString:_callbackEventId]];
}
↓マニュアルを見て修正しました。
- (void)_accessoryDidDisconnect:(NSNotification *)notification
{
EAAccessory *disconnectedAccessory = [[notification userInfo] objectForKey:EAAccessoryKey];
if ([disconnectedAccessory connectionID] == [[_service accessory] connectionID])
{
[_service closeSession];
NSLog(@"▼ScannerPlugin.m DidDisconnect -> close");
CDVPluginResult *result;
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"_accessoryDidDisconnect"];
[self writeJavascript:[result toSuccessCallbackString:_callbackEventId]];
}
}
補足
bluetoohデバイスが2つ以上あることを前提でコードを組まないといけませんね。
Xamarin、PhoneGap(Cordova)、Titaniumをやってきているが、以外なところでハマった。
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿