Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

zxcpoiu
Copy link
Contributor

@zxcpoiu zxcpoiu commented Aug 5, 2016

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.

@ghost
Copy link

ghost commented Aug 5, 2016

By analyzing the blame information on this pull request, we identified @skv-headless and @javache to be potential reviewers.

@ghost ghost added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Aug 5, 2016
@ghost
Copy link

ghost commented Aug 5, 2016

@zxcpoiu updated the pull request.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 5, 2016
@ghost
Copy link

ghost commented Aug 5, 2016

@zxcpoiu updated the pull request.

1 similar comment
@ghost
Copy link

ghost commented Aug 5, 2016

@zxcpoiu updated the pull request.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 5, 2016
@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 5, 2016
@ghost
Copy link

ghost commented Aug 5, 2016

@zxcpoiu updated the pull request.

1 similar comment
@ghost
Copy link

ghost commented Aug 5, 2016

@zxcpoiu updated the pull request.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 5, 2016
@ghost
Copy link

ghost commented Aug 5, 2016

@zxcpoiu updated the pull request.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 5, 2016
@zxcpoiu zxcpoiu closed this Aug 5, 2016
@zxcpoiu zxcpoiu reopened this Aug 5, 2016
@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 5, 2016
@zxcpoiu
Copy link
Contributor Author

zxcpoiu commented Aug 5, 2016

Fixed ci

@javache
Copy link
Member

javache commented Aug 25, 2016

@facebook-github-bot shipit

@ghost ghost added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Aug 25, 2016
@ghost
Copy link

ghost commented Aug 25, 2016

Thanks for importing.If you are an FB employee go to Phabricator to review internal test results.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 25, 2016
@ghost ghost closed this in 2cfe774 Aug 26, 2016
rozele pushed a commit to microsoft/react-native-windows that referenced this pull request Sep 14, 2016
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 pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants