#using push notifications component in monorepo with react native expo

6 messages · Page 1 of 1 (latest)

eternal yarrow
#

Hi all. I am attempting to use the new convex component expo push notifications. I have a monorepo (using turbo-repo + pnpm) with 2 apps: a react-native expo (SDK 52) app and my convex backend. This is (roughly) the monorepo project structure

apps/
  convex/ 
  expo/
package.json

In my expo application, I import various functions from the expo-notifications lib. E.g to retrieve the push token:

import * as Notifications from "expo-notifications";
...
const token = await await Notifications.getExpoPushTokenAsync();

But I'm observing that if I install the convex dependency @convex-dev/expo-push-notifications in the monorepo, it seems to be messing up something with the expo-notifications lib in the client app because I get the following error at the import statement:

Cannot read property `prototype` of undefined

If I remove the convex dependency from the monorepo then the client app works again without issue. I can't tell if the issue is with my monorepo setup or something else. But this error occurs every time I install @convex-dev/expo-push-notifications as a dependency in the monorepo

fathom garnet
eternal yarrow
#

Hi @fathom garnet thanks for the reply. I have not installed react-navigation in my native app. But I'm using the latest expo-router which I believe uses react-navigation internally. Not sure how I will restrict a single version of react-navigation.

eternal yarrow
#

I picked a look into @convex-dev/expo-push-notifications node_modules, I see that it is using
"expo-notifications": "^0.28.16",

In my expo application, I'm using "expo-notifications": "~0.29.8",. Not sure if this is causing some conflict...

I hope someone from the convex team could help me understand or address this issue.

fathom garnet
eternal yarrow
#

@fathom garnet Thanks. I have upgraded to latest Expo 52 (which means latest expo-router and latest expo-notifications). So I cannot downgrade the version I'm using in the expo app.

I'm using pnpm monorepo and I'm making sure to install @convex-dev/expo-push-notifications inside the /apps/convex folder so that it does not affect the rest of the monorepo by first cd /apps/convex and then run pnpm add @convex-dev/expo-push-notifications. This has not fixed the issue.

Then I have attempted to stick expo-notifications version for the whole monorepo by adding overrides to the root package.json:

  "overrides": {
    "expo-notifications": "~0.29.8"
  },

Unfortunately I'm observing the same behaviour. I'm wondering if I could find a working example with monorepo and convex push notifications.