-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ios: complete iOS vibration pattern supports (js) #9233
Conversation
By analyzing the blame information on this pull request, we identified @skv-headless and @javache to be potential reviewers. |
dcd4955
to
0bd1ace
Compare
@zxcpoiu updated the pull request. |
0bd1ace
to
a8cb818
Compare
@zxcpoiu updated the pull request. |
1 similar comment
@zxcpoiu updated the pull request. |
a8cb818
to
d0d460d
Compare
@zxcpoiu updated the pull request. |
1 similar comment
@zxcpoiu updated the pull request. |
d0d460d
to
6fb623b
Compare
@zxcpoiu updated the pull request. |
Fixed ci |
@facebook-github-bot shipit |
Thanks for importing.If you are an FB employee go to Phabricator to review internal test results. |
2cfe774
Summary: This is a revised follow up version from #8574 ( originally implemented in `objc` ) This PR change the implementation in JS suggested by javache **motivation** To supports vibration pattern like android. The [iOS vibration implementation link](http://stackoverflow.com/questions/12966467/are-there-apis-for-custom-vibrations-in-ios/13047464#13047464) mentioned by skv-headless at facebook/react-native#6061 (comment), which will not be accepted by apple since that implementation uses a private API. Thus, I use pure public API `NSTimer` to implement it. **Note** Since vibration time on iOS is not configurable, there are slightly differences with android. for example: **Android Usage:** `Vibration.vibrate([0, 500, 200, 500])` ==> V(0.5s) --wait(0.2s)--> V(0.5s) `Vibration.vibrate([300, 500, 200, 500])` ==> --wait(0.3s)--> V(0.5s) --wait(0.2s)--> V(0.5s) **iOS Usage:** if first argument is 0, it will not be included in pattern array. ( vibration Closes facebook/react-native#9233 Differential Revision: D3775085 Pulled By: javache fbshipit-source-id: 370495857d5581399de32d2bed1ea1bcce193e9d
This is a revised follow up version from #8574 ( originally implemented in
objc
)This PR change the implementation in JS suggested by @javache
motivation
To supports vibration pattern like android.
The iOS vibration implementation link mentioned by @skv-headless at #6061 (comment), which will not be accepted by apple since that implementation uses a private API. Thus, I use pure public API
NSTimer
to implement it.Note
Since vibration time on iOS is not configurable, there are slightly differences with android.
for example:
Android Usage:
Vibration.vibrate([0, 500, 200, 500])
==> V(0.5s) --wait(0.2s)--> V(0.5s)
Vibration.vibrate([300, 500, 200, 500])
==> --wait(0.3s)--> V(0.5s) --wait(0.2s)--> V(0.5s)
iOS Usage:
if first argument is 0, it will not be included in pattern array.
( vibration length on iOS is about 500ms )
Vibration.vibrate([0, 1000, 2000, 3000])
==> V(fixed) --wait(1s)--> V(fixed) --wait(2s)--> V(fixed) --wait(3s)--> V(fixed)
Vibration.vibrate([0, 1000, 2000, 3000], true)
==> V(fixed) --wait(1s)--> V(fixed) --wait(2s)--> V(fixed) --wait(3s)--> V(fixed) --wait(1s)--> V(fixed) --wait(2s)--> V(fixed) --wait(3s)--> V(fixed)
Vibration.vibrate([1000, 2000], true)
==> --wait(1s)--> V(fixed) --wait(2s)--> V(fixed) --wait(1s)--> V(fixed) --wait(2s)--> V(fixed)
Vibration.vibrate([0, 1000], true)
==> V(fixed) --wait(1s)--> V(fixed) --wait(1s)--> V(fixed)
Test plan (required)
I also added examples in
UIExplorer
.Open
UIExplorer
on iOS, and plays it around.