10 ms·
What I did some time ago was create two native projects, drop in a WebView, write most code in C++, then use a single shared C++ header for things like bluetoot
by edg5000 3y ago
What I did some time ago was create two native projects, drop in a WebView, write most code in C++, then use a single shared C++ header for things like bluetooth. This functionality is implemented in a C++ file for Android and an ObjC++ file for iOS. On Android you use JNI to access the Java Bluetooth API's and on iOS you can directly invoke the iOS Bluetooth libraries using Objective-C.
The WebView on Android and iOS supports configuring an interop function. It allows you to map a JavaScript function to Java/ObjC functions. In my case, I had a single function with a single string argument, which I used to pass JSON messages.
I then implemented a callback mechanism where each message would get a unique ID. From JavaScript code, I could call a function in the shared C++ core and get a callback when data is returned.
The shared C++ code can directly access the internet and filesystem (I read in another comment that they changed this recently?).
The performance of the WebView is amazing, especially if you just rawdog it and write plain JavaScript. Modern JavaScript is nothing like it was back in the IE6 days.
With flat UIs, at the end of the day, who cares that it "doesn't feel native". What price are you willing to pay just so that it "feels native"?