SoI有一个使用他们的api连接的设备(unimag II)我重写了他们的一些方法,以便与我希望我的应用程序流动和运行的方式兼容。但是,我现在遇到的问题包括[UM Info] SDK: initialized
UM Warning] StartSwipe: UMRET_NO_READER
以及其他通知时未被点击的swipe starting
。显然我错过了一些东西,但是我已经把这么多时间花在了这上面,因为我确信我尽可能地接近他们的示例应用程序,所以我不知道我可能会错过什么。显然有更多的代码,但这应该是设置为打开我认为
-(void)enableSwipe:(CDVInvokedUrlCommand*)command{
[self umsdk_activate];
UmRet ret = [uniReader requestSwipe];
[self displayUmRet: @"Starting swipe task" returnValue: ret];
}
-(void) umsdk_registerObservers:(BOOL) reg {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
//list of notifications and their corresponding selector
const struct {NSString __unsafe_unretained *n; SEL s;} noteAndSel[] = {
//
{uniMagAttachmentNotification , @selector(umDevice_attachment:)},
{uniMagDetachmentNotification , @selector(umDevice_detachment:)},
//
{uniMagInsufficientPowerNotification, @selector(umConnection_lowVolume:)},
{uniMagMonoAudioErrorNotification , @selector(umConnection_monoAudioError:)},
{uniMagPoweringNotification , @selector(umConnection_starting:)},
{uniMagTimeoutNotification , @selector(umConnection_timeout:)},
{uniMagDidConnectNotification , @selector(umConnection_connected:)},
{uniMagDidDisconnectNotification , @selector(umConnection_disconnected:)},
//
{uniMagSwipeNotification , @selector(umSwipe_starting:)},
{uniMagTimeoutSwipeNotification , @selector(umSwipe_timeout:)},
{uniMagDataProcessingNotification , @selector(umDataProcessing:)},
{uniMagInvalidSwipeNotification , @selector(umSwipe_invalid:)},
{uniMagDidReceiveDataNotification , @selector(umSwipe_receivedSwipe:)},
//
{uniMagCmdSendingNotification , @selector(umCommand_starting:)},
{uniMagCommandTimeoutNotification , @selector(umCommand_timeout:)},
{uniMagDidReceiveCmdNotification , @selector(umCommand_receivedResponse:)},
//
{uniMagSystemMessageNotification , @selector(umSystemMessage:)},
{nil, nil},
};
//register or unregister
for (int i=0; noteAndSel[i].s != nil ;i++) {
if (reg)
[nc addObserver:self selector:noteAndSel[i].s name:noteAndSel[i].n object:nil];
else
[nc removeObserver:self name:noteAndSel[i].n object:nil];
}
}
-(void) umsdk_activate {
//register observers for all uniMag notifications
[self umsdk_registerObservers:TRUE];
NSLog(@"activating");
//enable info level NSLogs inside SDK
// Here we turn on before initializing SDK object so the act of initializing is logged
[uniMag enableLogging:TRUE];
//initialize the SDK by creating a uniMag class object
uniReader = [[uniMag alloc] init];
/*
//set SDK to perform the connect task automatically when headset is attached
[uniReader setAutoConnect:TRUE];
*/
//set swipe timeout to infinite. By default, swipe task will timeout after 20 seconds
[uniReader setSwipeTimeoutDuration:0];
//make SDK maximize the volume automatically during connection
[uniReader setAutoAdjustVolume:TRUE];
//By default, the diagnostic wave file logged by the SDK is stored under the temp directory
// Here it is set to be under the Documents folder in the app sandbox so the log can be accessed
// through iTunes file sharing. See UIFileSharingEnabled in iOS doc.
[uniReader setWavePath: [NSHomeDirectory() stringByAppendingPathComponent: @"/Documents/audio.caf"]];
}