Am currently trying to setup notifications on my managed expo project
47.0.0
0.17.0
12
I am currently just trying to get the basic setup itself working and retrieve my devices push token. This should be done using Notifications.getExpoPushTokenAsync()
as described here.
My error is strange, when I call getExpoPushTokenAsync
it does indeed get me the expo push token, however shortly after my app crashes with the following messages
ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[1], "../../../src/util").types.isPromise')
WARN [expo-notifications] Error encountered while updating server registration with latest device push token. [TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[5], "@ide/backoff").computeNextBackoffInterval')]
I have tried
node_modules
and expo-notifications
but still get the same.@ide/backoff
package is installed in my node_modules
.One other interesting thing is that I can call Notifications.getDevicePushTokenAsync()
fine with no error. But still get the same error if i pass that in to getExpoPushTokenAsync
method after. At a surface level it seems like somehow the request out to expo services to get the expo push token is both passing and failing 🤷♂️
const devicePushTokenResponse = await Notifications.getDevicePushTokenAsync();
const expoPushTokenResponse = await Notifications.getExpoPushTokenAsync({
devicePushToken: devicePushTokenResponse,
}); // <--- Returns token & errors a few seconds later
Couldn't see any other posts with this error and expo-notifications
, so would be keen to see if anyone else has ran into / fixed a similar issue recently
Cheers
Alright I figured it out, it was somewhat hinted at by this line
ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[1], "../../../src/util").types.isPromise')
And more specifically the fact that a node_modules
dependency is referencing 3 levels up in the file system.
Turns out that for some reason my module resolver (defined in babel.config.js
) was resolving my project's util
folder instead of the packages util folder. I think this was compounded by my metro config making use of the inlineRequires
functionality to improve performance (see more)
I am sure there is some actual config that could be updated to exclude node_modules
from using inline requires (i did try use a blocklist to no avail), but as an interim, i was able to get it working fine by changing the path of my util
folder to be @my-project/util
so that it avoids future collisions.
Hope this helps anyone who runs into the same issue in the future :)