iOS Question Vibrate Phone (Short Vibrate)

Discussion in 'iOS Questions' started by aaronk, Jul 5, 2019.

  1. aaronk

    aaronk Well-Known Member Licensed User

    Hi,

    I am trying to make the phone vibrate when a button is pressed.

    I have found that I can use code like:

    Code:
    Dim vib As Phone
        vib.Vibrate
    However, when I use this code it seems that it vibrates the phone for approx 1 second.

    Is there a way in making it vibrate the phone for 100-200ms (like a short keypress vibrate) rather than a long vibration like it's doing now ?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    1.
    Code:
    Private FeedbackGenerator As NativeObject 'globals
    2. Initialize:
    Code:
    FeedbackGenerator.Initialize("UIImpactFeedbackGenerator")
    If FeedbackGenerator.IsInitialized Then
       FeedbackGenerator = FeedbackGenerator.RunMethod(
    "alloc"Null).RunMethod("initWithStyle:"Array(0)) 'light
    End If
    3. Vibrate:
    Code:
    If FeedbackGenerator.IsInitialized Then
               FeedbackGenerator.RunMethod(
    "impactOccurred"Null)
           
    End If
     
  3. aaronk

    aaronk Well-Known Member Licensed User

    Thanks heaps, works a treat.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice