Reputation: 119
I'm trying to find a way of doing this, but so far with a bunch of googling I can't seem to find anything. Maybe I'm searching for the wrong thing, but I'd like to include haptics into my app if I could as a user experience thing. I can't seem to find any information on google about doing this so I figured I'd reach out to you guys.
Does anyone know how to incorporate haptics into a NativeScript mobile app? If so how would I go about doing this? I've tried TapticEngine, but that doesn't seem to work.
Upvotes: 1
Views: 1475
Reputation: 127
For triggering a haptic/taptic feedback in your angular app you can use the following line of code, where the vibration will be 500ms long:
window.navigator.vibrate(500);
Here you will find a documentation.
Please notice that this feature only works on mobile devices on supported browsers. Safari does not support this functionality
Upvotes: 0
Reputation: 2472
You can do that in NativeScript by either using the Taptic Engine plugin or by simply calling the native functions directly, like this:
let feedbackGenerator = UINotificationFeedbackGenerator.alloc().init();
feedbackGenerator.notificationOccurred(UINotificationFeedbackType.Success);
feedbackGenerator = null;
But I would recommend you use the plugin.
Upvotes: 1