-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |