Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
stardomains
Posts: 172
Registered: ‎12-14-2009
My Device: Not Specified
Accepted Solution

Vibrate in BB10 Webworks?

I saw that you can do vibrate in BB10 WebWorks here:

 

https://github.com/blackberry/WebWorks-Community-APIs/issues/101

 

navigator.vibrate is supported already "

 

I have tried navigator.vibrate I can't get it to work. I tried navigator.vibrate, navigator.vibrate(); navigator.vibrate(1000), navigator.vibrate([50, 100, 150]);

 

Does anyone know how to get it to work? Do you need a permissions element in the config?

 

http://dev.w3.org/2009/dap/vibration/

Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: Vibrate in BB10 Webworks?

navigator.vibrate should be working, what device build are you trying?
@nukulb
Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: Vibrate in BB10 Webworks?

You need navigator.webkitvibrate
@nukulb
Please use plain text.
Developer
stardomains
Posts: 172
Registered: ‎12-14-2009
My Device: Not Specified

Re: Vibrate in BB10 Webworks?

[ Edited ]

I just tried three different cases:

 

1st try: navigator.webkitvibrate;

2nd try: navigator.webkitvibrate(2000);

3rd try: navigator.webkitvibrate([50, 100, 150]);

 

And it didn't work for me.

 

Worked with:

 

navigator.webkitVibrate(2000);

 

I needed the capitalized "V"!

 

Thanks!

 

Although with that code it keeps vibrating. It doesn't go for just 2 seconds. I'll keep experimenting.

 

...

 

navigator.webkitVibrate([2000]);

 

With brackets it will work for the 2 seconds.

 

...

 

This successfully did the pattern too:

 

navigator.webkitVibrate([1000,1000,1000,1000,1000,1000,1000,1000,1000,1000]);

 

 

Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: Vibrate in BB10 Webworks?

navigator.vibrate(1000) will work in the future.
@nukulb
Please use plain text.
Developer
Developer
LBP
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Vibrate in BB10 Webworks?

Hi Nukul and all others,

 

something changed in the API for virbation? I'm searching an event handler to make differentiate between playing a sound or vibrate in my App, but I couldn't find anything about it and you sample

 

navigator.vibrate(1000);

is throwing a:

TypeError: Type error

 

Is there a bug in the latest BB10 Version 10.0.9.1675 or something missing in the HTML5 documentation?


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: Vibrate in BB10 Webworks?

navigator.vibrate([1000])

AND

navigator.vibrate(1000)

both work for me

According to the spec that is correct
http://dev.w3.org/2009/dap/vibration/



@nukulb
Please use plain text.
Developer
Developer
LBP
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Vibrate in BB10 Webworks?

[ Edited ]

Hi Nukul,

 

I always get a type error with this when directly calling the navigator.vibrate(1000) in Web Inspector:

TypeError: Type error
line: 2
message: "Type error"
stack: "vibrate@[native code]↵eval code↵eval@[native code]↵evaluate@[native code]↵_evaluateOn↵_evaluateAndWrap↵evaluate↵[native code]"
> __proto__: Error

Is there something to be added to the config.xml for it to work?

 

BTW: Is there an event handler/listener to be able to vibrate instead of playing a sound if the BB10's volume is down/muted?

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Please use plain text.
Developer
Developer
LBP
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Vibrate in BB10 Webworks?

Hi everybody.

 

Any news on navigator.vibrate.

I'm running the latest BB10 SDK version 1.0.4.7 and BB10 Dev Alpha "A" OS version 10.0.9.2320 [10.9.9.339] but it doesn't work.

 

I always get the same errors running the samples provided by Nukul.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Please use plain text.