Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
miyabi authored Feb 14, 2018
1 parent a82a766 commit 7678d60
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# react-native-passkit-wallet
React Native module to handle PassKit.

## Usage
```jsx
import { PassKit, AddPassButton } from 'react-native-passkit-wallet'
```

### Check whether the device supports adding passes
```jsx
PassKit.canAddPasses()
.then((result) => {
console.log(result)
})
```

### Display a button that enables users to add passes to Wallet
```jsx
class App extends Component<{}> {
render() {
return (
<AddPassButton
style={styles.addPassButton}
addPassButtonStyle={PassKit.AddPassButtonStyle.black}
onPress={() => { console.log('onPress') }}
/>
)
}
}
```

### Show a pass and prompt the user to add that pass to the pass library
```jsx
PassKit.presentAddPassesViewController(base64EncodedPass)
```

### Handle events
```jsx
class App extends Component<{}> {
// To keep the context of 'this'
onAddPassesViewControllerDidFinish = this.onAddPassesViewControllerDidFinish.bind(this)

componentDidMount() {
// Add event listener
PassKit.addEventListener('addPassesViewControllerDidFinish', this.onAddPassesViewControllerDidFinish)
}

componentWillUnmount() {
// Remove event listener
PassKit.removeEventListener('addPassesViewControllerDidFinish', this.onAddPassesViewControllerDidFinish)
}

onAddPassesViewControllerDidFinish() {
// Add-passes view controller has been dismissed
console.log('onAddPassesViewControllerDidFinish')
}
}
```

### Constants
- *PassKit.AddPassButtonStyle* - The appearance of the add-pass button
- *black* - A black button with white lettering
- *blackOutline* - A black button with a light outline
- *PassKit.AddPassButtonWidth* - Default add-pass button width
- *PassKit.AddPassButtonHeight* - Default add-pass button height

0 comments on commit 7678d60

Please sign in to comment.