We have built a basic iOS app that initialises the MirrorCoreSDK and sends a dictionary:
{ template: "default", name: "george" }
when a button is pressed.
I have made a template for the Mirror which uses the JavaScript API, however I am having an issue where the ‘ondata’ function runs once the Mirror has been reset (Mirror drive ejected then waiting), despite the app being completely closed in multitasking on the iPhone and Bluetooth being switched off before the Mirror is reset. This is strange as the data should be completely unavailable to the Mirror due to the iPhone not broadcasting any data - is it pulling it from a cache some how?
If you eject MIRROR drive, it will synchronise templates and then refresh current template, replaying ondata calls from cache (and then it will remount itself again). This is done to speed up development (you don’t need to repeat all phone actions) and would not happen during production use.
Every template that is invoked remotely or via switchTemplate will receive ‘ondata’ call with all parameters it needs. It makes ‘ondata’ convenient place to fill your template with data. However default template is not invoked by user interaction, but just by device reboot. To be consistent and make life a bit easier ondata is also called when device starts, but this time with empty data. In future this will allow to parametrise default template via config tools.
This caching is main purpose is for browser process crash recovery (displays are usually on all the time, so better be safe than sorry). Mirror is trying to replay all USER_DATA calls to restore previous template state. It does it without any delay so it is important for template to handle this case. Invalidating cache will turn this recovery procedure off.
Cache is cleared each time template is switched to other one, since cached events were relevant to previous template. So in order to reset cache you need to switch forth and back to other template.