Installation
Install the WalletConnect NotifyClient package.
- npm
- Yarn
- Bun
- pnpm
npm install @walletconnect/notify-client @walletconnect/react-native-compat
yarn add @walletconnect/notify-client @walletconnect/react-native-compat
bun add @walletconnect/notify-client @walletconnect/react-native-compat
pnpm add @walletconnect/notify-client @walletconnect/react-native-compat
You will need to polyfill crypto depending on your environment. See instructions below.
- Expo
- React Native CLI
- npm
- Yarn
- Bun
- pnpm
npm i expo-crypto
yarn add expo-crypto
bun a expo-crypto
pnpm add expo-crypto
- Create a file called
expo-crypto-shim.js
at the root of your project - Go to
expo-crypto-shim.js
and paste the following snippet into it.
import { digest } from 'expo-crypto'
// eslint-disable-next-line no-undef
const webCrypto = typeof crypto !== 'undefined' ? crypto : new Crypto()
webCrypto.subtle = {
digest: (algo, data) => {
const buf = Buffer.from(data)
return digest(algo, buf)
}
}
;(() => {
if (typeof crypto === 'undefined') {
Object.defineProperty(window, 'crypto', {
configurable: true,
enumerable: true,
get: () => webCrypto
})
}
})()
- Then head over your
index.js
file at the root of your project and add the following imports.
import '@walletconnect/react-native-compat'
import './expo-crypto-shim.js'
- npm
- Yarn
- Bun
- pnpm
npm i react-native-quick-crypto react-native-quick-base64 stream-browserify @craftzdog/react-native-buffer babel-plugin-module-resolver
yarn add react-native-quick-crypto react-native-quick-base64 stream-browserify @craftzdog/react-native-buffer babel-plugin-module-resolver
bun a react-native-quick-crypto react-native-quick-base64 stream-browserify @craftzdog/react-native-buffer babel-plugin-module-resolver
pnpm add react-native-quick-crypto react-native-quick-base64 stream-browserify @craftzdog/react-native-buffer babel-plugin-module-resolver
For iOS only
cd ios && pod install
- Go to your
index.js
file at the root of your project and add the following polyfill
import { AppRegistry } from 'react-native'
import App from './App'
import { name as appName } from './app.json'
import crypto from 'react-native-quick-crypto'
const polyfillDigest = async (algorithm, data) => {
const algo = algorithm.replace('-', '').toLowerCase()
const hash = crypto.createHash(algo)
hash.update(data)
return hash.digest()
}
globalThis.crypto = crypto
globalThis.crypto.subtle = {
digest: polyfillDigest
}
AppRegistry.registerComponent(appName, () => App)
- Update your
babel.config.js
with the following configuration
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
alias: {
'crypto': 'react-native-quick-crypto',
'stream': 'stream-browserify',
'buffer': '@craftzdog/react-native-buffer',
},
},
],
...
],
};
Next Steps
Now that you've installed WalletConnect Notify, you're ready to start integrating it. The next section will walk you through the process of setting up your project to use the Notify API.
Was this helpful?