npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-passkit-wallet

v0.1.6

Published

React Native module to handle PassKit pass.

Downloads

38,108

Readme

react-native-passkit-wallet

React Native module to handle PassKit pass.

Installation

1. Install library from npm

npm install --save react-native-passkit-wallet

2. Link native code

You can link native code in the way you prefer:

CocoaPods

Add line to your project target section in your Podfile:

target 'YourProjectTarget' do

+   pod 'react-native-passkit-wallet', path: '../node_modules/react-native-passkit-wallet'

end

If you received error jest-haste-map: Haste module naming collision: Duplicate module name: react-native, add lines below to your Podfile and reinstall pods.

target 'YourProjectTarget' do

+   rn_path = '../node_modules/react-native'
+   pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
+   pod 'React', path: rn_path

  pod 'react-native-passkit-wallet', path: '../node_modules/react-native-passkit-wallet'

end

+ post_install do |installer|
+   installer.pods_project.targets.each do |target|
+     if target.name == "React"
+       target.remove_from_project
+     end
+   end
+ end

react-native link

Run command below:

react-native link react-native-passkit-wallet

3. Android configuration

  1. Add following lines to AndroidManifest.xml

    <manifest
      ...
    + xmlns:tools="http://schemas.android.com/tools"
    >
      <application ...>
        ...
    +   <provider
    +     android:name="androidx.core.content.FileProvider"
    +     android:authorities="com.yourcompany.fileprovider"
    +     android:grantUriPermissions="true"
    +     android:exported="false"
    +     tools:replace="android:authorities">
    +     <meta-data
    +       android:name="android.support.FILE_PROVIDER_PATHS"
    +       android:resource="@xml/passkit_file_paths"
    +       tools:replace="android:resource" />
    +   </provider>
      </application>
    </manifest>
  2. Create passkit_file_paths.xml

    Create passkit_file_paths.xml file in your project's android/app/src/main/res/xml directory. pkpass file will be created in your app's cache directory.

    <paths xmlns:android="http://schemas.android.com/apk/res/android">
        <cache-path name="passkit" path="/"/>
    </paths>

Usage

import PassKit, { AddPassButton } from 'react-native-passkit-wallet'

Check whether the device supports adding passes

PassKit.canAddPasses()
  .then((result) => {
    console.log(result)
  })

For Android, true will be returned if apps that can open pkpass files are installed.

Prompt the user to add the pass to the pass library

PassKit.addPass(base64EncodedPass)

For Android, file provider has to be specified for the second argument. And a dialogue box will appear to choose an app to open the pass.

PassKit.addPass(base64EncodedPass, 'com.yourcompany.fileprovider')

Check whether the user’s pass library contains the specified pass (iOS only)

PassKit.containsPass(base64EncodedPass)

Display a button that enables users to add passes to Wallet (iOS only)

class App extends Component<{}> {
  render() {
    return (
      <AddPassButton
        style={styles.addPassButton}
        addPassButtonStyle={PassKit.AddPassButtonStyle.black}
        onPress={() => { console.log('onPress') }}
      />
    )
  }
}

Handle events (iOS only)

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 (iOS only)

  • 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