create-react-native-app icon indicating copy to clipboard operation
create-react-native-app copied to clipboard

Expo Notification undefined is not a function

Open halallahh opened this issue 9 years ago • 5 comments

Please make our job easier by filling this template out to completion. If you're requesting a feature instead of reporting a bug, please feel free to skip the Environment and Reproducible Demo sections.

Description

this error msg TypeError: undefined is not a function appear when run this code let token = await Notifications.getExpoPushTokenAsync();

Expected Behavior

What action did you perform, and what did you expect to happen? to get the push token

Observed Behavior

What actually happened when you performed the above actions?

6:45:13 PM: Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not a function (evaluating '_expo.Notifications.getExpoPushTokenAsync()')

Environment

Please run these commands in the project folder and fill in their results:

    "sdkVersion": "18.0.0",

Also specify:

  1. Operating system: elementary OS 0.4.1 Loki
  2. Phone & version: Android Lolipop

halallahh avatar Aug 29 '17 10:08 halallahh

For other people who landed here googling this error, I think the problem is that the function is correctly called getExponentPushTokenAsync instead of getExpoPushTokenAsync like the example given in the documentation.

brynnb avatar Nov 09 '17 03:11 brynnb

in sdk22 and higher it is getExpoPushTokenAsync: https://github.com/expo/expo-sdk/blob/6ea86aa8415f42a3991e193d7e379d1fc90b7246/src/Notifications.js#L127-L130

brentvatne avatar Nov 15 '17 01:11 brentvatne

Thanks @brentvatne, that makes a lot more sense. I appreciate all the expo work you do. It's helped me tremendously and you're awesome.

brynnb avatar Nov 15 '17 02:11 brynnb

hello, I am quite new to react native and I am facing the same issue. @brynnb can you please guide me on how did u actually resolved this push notification error and what is the endpoint I am missing upon?

kanikas24 avatar May 02 '18 07:05 kanikas24

Apologies @kanikas24, been a long time since I did this and I don't recall more than what I posted above.

brynnb avatar May 02 '18 09:05 brynnb