3

I'm being called upon to build a web app that interfaces with an iphone accessory. I see that native apps use the ExternalAccessory.framework to access accessory, but so far I'm seeing no indication that this framework is in any way exposed for web apps. Is this possible (and if so, what is the entry point), or do we just need to build native?

anthropomo
  • 4,100
  • 1
  • 24
  • 39

1 Answers1

2

What you're likely going to have to do is use a native app as a layer of communication between the iOS accessory and the web server. In other words you're going to have to intercept all of the responses from the web server and translate those for the accessory via native objective-C. If you write a native app with a viewcontroller that is a UIWebViewController and either have the web server bake in command payloads in its response messages or gruelingly parse the HTML for embedded commands you can pull it off. My company uses a 3rd party accessory in this manner and while it's not pretty it works. I mean "not pretty" in the sense that your commands are static per your app build and underlying handling of the accessory. Good luck!

Quick EDIT: Depending on how re-usable you want to make interfacing with this accessory you could always create a framework with the commands baked in. That way when you need to alter or expand the command/control schema all you have to do is change the framework (yes, that will require a build). It will also allow you to easily adopt the same control across multiple apps in a fast manner.

Dan
  • 5,153
  • 4
  • 31
  • 42
  • This is more or less what I have come to. We are probably going to build native, do all the processing device side and send results via TCP since the server details are within our control. Care to expand on "web server bake in command payloads"? – anthropomo Jul 22 '13 at 14:30
  • If my app navigates to www.mysite.com/page2.aspx you can essentially have the web server respond with something (and this is an arbitrary, simplified example) like "doCommand=3&option=2.5". In your native code you can then break down what the server responded with and say, "ok... I see I'm supposed to now turn on that LED (that's doCommand 3) and make it blink 5 times (that's option 2.5). In all reality once you start opening up Pandora's Box as per what you want to do with your accessory you literally can do anything you want BUT the tradeoff is changes = builds. – Dan Jul 22 '13 at 15:05
  • When it comes to the communication between the native code and the web view, my only suggestion is don't try to roll your own from scratch. Lots of people have done this type of thing before and you should at least look at how they did it before reinventing the wheel. – funroll Dec 04 '13 at 18:08