*Note: I started this venture on the community slack, but due to the limitations of free accounts, I've decided to share my discoveries here so that they don't disappear in the future. Thank you to @bolav @uldis and for all their guidance on how to go about solving this challenge. *
This is a work in progress and I plan to update this thread as I learn learn how to implement this be the through experimentation and community feedback.
In order to detect a shake gesture I'll need to leverage the Core Motion framework, but the challenge is that to utilize this we need to overwrite
YES and implement the
motionBegan:withEvent defined in
UIResponsder, the the superclass for the both
UIViewController classes. Fortunately in a fuse app, the AppDelegate is actually extends the
UIViewController class, so in order be minimally invasive with my solution, I chose to create a new class
FuseAppDelegate which also extends the
So now I can just change the base class in the generated AppDelegate, like so:
Later this step can be implemented with some sort of build script.
In this class I'll implement the necessary methods to detect a shake gesture natively, but I'll get to that part later. First I need to create an
.uno module that will be converted by fusion when the project is built. I created a
Shaker.uno file in my project:
This module creates a simple singleton with method
ShakeDetected(). This part took a while to figure out, repeatedly regenerating the project and figuring out how to how to access them on the other side. Finally I arrived at the solution of using a singleton, because it made invoking the method from Objective-C more straight forward and I'm a noob to using Uno. Here are the details of my
And the results when I shake connected device is a success!
Again, this is a very rough experimentation and hope to refine the solution over time, posting discoveries here.