Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/haptic feedback #110

Merged
merged 7 commits into from Dec 6, 2018
Merged

Conversation

StriderHND
Copy link
Contributor

@StriderHND StriderHND commented Dec 5, 2018

This is a PR about the Feature Request #102 that the implementation of Haptic Feedback.

The usage of haptic feedback has been implemented using WKWebViewConfiguration and WKUserContentController to listen at the events of the webApp doing calls via webkit.messageHandlers on the Native side in the ViewController class is conforming the WKScriptMessageHandler protocol to get the type of data needed to perform the actions required by the webApp.

for example if we want to have a haptic action in any place of the webApp we have 3 feedback types:

  1. heavy
  2. medium
  3. light

Execute the haptic we must add the following code in where we want the haptic happens:

<script>
 
  function hapticExampleFunction() {

      this is the main implementation the rest of the function can vary.
      window.webkit.messageHandlers.haptic.postMessage("light");
  }
  window.onload = hapticExampleFunction;

</script>

we could expand using the WKScriptMessageHandler to other webApp -> native communication because we can send JSON objects to the native side via the WKScriptMessage that supports basic dataTypes.

If you have questions, let me know

Erick

@benhalpern
Copy link
Contributor

This looks really great. I'll review it within the next day.

@benhalpern
Copy link
Contributor

Hmmmm in my first attempt, I'm getting the window.webkit.messagehandlers undefined error.

Seems to bring me here, but that is already in, right?

https://stackoverflow.com/questions/32771215/wkwebkit-javascript-on-loaded-page-finds-window-webkit-is-undefined

May be something more on my end. I'll keep testing. Have you tested it in any way on your machine by loading a local version of dev.to (or a dummy site that just triggers window.webkit.messageHandlers.haptic.postMessage("light");)?

@StriderHND
Copy link
Contributor Author

StriderHND commented Dec 6, 2018

Let me check that pretty fast because the handler lister is there. @benhalpern

I did some test in my local machine with a local dev.to and a dummy site.

@StriderHND
Copy link
Contributor Author

@benhalpern I've made some changes from how the configuration for the webView is set. can you try again please.

@benhalpern benhalpern merged commit d2f6a7b into forem:master Dec 6, 2018
@StriderHND StriderHND deleted the feature/haptic-feedback branch December 6, 2018 21:58
@chickdan chickdan mentioned this pull request Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants