6
\$\begingroup\$

I'm building a web game. I'm trying to use the iPhone's vibration functionality. How would I go about doing this seeing I want to package and deploy this game to the App Store. Is there a secured way to do this?

\$\endgroup\$
  • \$\begingroup\$ First hit on google: davidwalsh.name/vibration-api \$\endgroup\$ – Bálint Jun 29 '17 at 21:37
  • \$\begingroup\$ I'm removing that second question since it seems unrelated & something to ask separately. \$\endgroup\$ – doppelgreener Jun 29 '17 at 21:45
  • \$\begingroup\$ @Bálint - I'm fully aware of David Walsh' blog post. I know the HTML5 vibration spec. It is not supported well cross browser and the fact that I need to have the game deployed in the App Store is actually the point of me asking. \$\endgroup\$ – Kriem Jun 29 '17 at 21:53
  • \$\begingroup\$ @doppelgreener - See my comment on Bálint. It actually is relevant. \$\endgroup\$ – Kriem Jun 29 '17 at 21:54
  • 1
    \$\begingroup\$ @Kriem Thanks, that makes sense. I thought you were asking separately about regular packaging and deployment of an app, but this clarifies it. :) \$\endgroup\$ – doppelgreener Jun 29 '17 at 22:14
5
+100
\$\begingroup\$

As you have found out, the W3C Vibration API is not supported in the iOS Safari browser (as reported here: https://caniuse.com/#feat=vibration).

However, you've pointed out that you plan to package your app for the iOS App Store. To do this, you'll need to package your "web game" into an appropriate native container for installation on the phone.

You could try to write your own app using the WKWebView component and catching JavaScript events to handle the vibration function natively, but there are already several app frameworks that do that for you. Each of them supports accessing the phone's vibration function, either from JavaScript or via native code. I'd recommend experimenting with them both and going with whichever works best for you:

  • Adobe PhoneGap
  • React Native
\$\endgroup\$
  • \$\begingroup\$ Intel_XDK its another one. \$\endgroup\$ – Undume Jul 5 '17 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.