VibrationManageriOS¶
Overview¶
A class that controls vibrations when running the sim in a native iOS App. It sends messages form the simulation WebView to its containing native swift application. This is the only way to request vibration on that platform since Web vibration is not supported in Safari.
This is a prototype, and this strategy has since been abandoned. We have since moved on to explore vibration in Android devices, where tablets have vibration support. There we can use the web vibration API and also use native android vibration for more sophisticated things like vibration intensity. @author Jesse Greenberg (PhET Interactive Simulations)
Class VibrationManageriOS¶
@deprecated - This strategy is being abandoned for an android specific solution.
Constructor¶
new VibrationManageriOS()¶
Instance Methods¶
vibrate( seconds : number )¶
Start a timed vibration for the provided time in seconds.
vibrateForever()¶
Start a vibration that will continue forever.
vibrateContinuous( providedOptions? : VibrateOptions )¶
Request a continuous vibration with provided parameters. This should replace all other functions in the future.
vibrateTransient( providedOptions? : VibrateOptions )¶
Request a transient vibration. A transient vibration is a single pulse at a particular time without any duration. It is used typically for basic UI components to indicate successful activation or change. Use vibrateContinuous for longer and more complicated vibrations.
vibrateAtFrequency( seconds : number, frequency : number )¶
Start a vibration for the provided duration, with a provided frequency.
vibrateAtFrequencyForever( frequency : number, intensity? : number )¶
Vibrate at the desired frequency. @param frequency @param [intensity] - from 0 to 1
vibrateWithCustomPattern( vibrationPattern : number[], seconds : number, loopForever : boolean )¶
Request a vibration with a custom pattern that loops forever. @param vibrationPattern - alternating values where even indexes are "on" time, odd indices are "off" @param seconds - time in seconds, how long to run the vibration @param loopForever - should this loop forever?
vibrateWithCustomPatternDuration( vibrationPattern : number[], seconds : number )¶
Vibrate with a custom pattern for the provided duration. @param vibrationPattern - alternative values where even indexes are "on" time and odd indexes are "off" @param seconds
vibrateWithCustomPatternForever( vibrationPattern : number[] )¶
Vibrate with a custom pattern forever. @param vibrationPattern - alternating values of "on" and "off" time in seconds, starting with "on" time.
setVibrationIntensity( intensity : number )¶
Sets the intensity of the current vibration. No effect if there is no active vibration. @param intensity - from 0 to 1
setVibrationSharpness( sharpness : number )¶
Sets the sharpness for the current vibration. No effect if there is no active vibration. @param sharpness - from 0 to 1
stop()¶
Stop any active vibration immediately.
saveTestEvents( dataString : string )¶
Saves the provided data string to the containing Swift app. Data string is generated by VibrationTestEventRecorder. @param dataString - the string to save
debug( debugString : string )¶
Send a debug message to the containing app that will be printed in the debugging tools.
Source Code¶
See the source for VibrationManageriOS.ts in the tappi repository.