9
\$\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\$
6
  • \$\begingroup\$ First hit on google: davidwalsh.name/vibration-api \$\endgroup\$
    – Bálint
    Jun 29, 2017 at 21:37
  • \$\begingroup\$ I'm removing that second question since it seems unrelated & something to ask separately. \$\endgroup\$ Jun 29, 2017 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, 2017 at 21:53
  • \$\begingroup\$ @doppelgreener - See my comment on Bálint. It actually is relevant. \$\endgroup\$
    – Kriem
    Jun 29, 2017 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\$ Jun 29, 2017 at 22:14

1 Answer 1

7
+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\$
1
  • \$\begingroup\$ Intel_XDK its another one. \$\endgroup\$
    – Undume
    Jul 5, 2017 at 7:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .