-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"undefined is not an object" when importing Notifications library #11855
Comments
Hello, @carlos-lao and thanks for opening this issue. After looking at your dependencies, it appears you might be on v4.3.46 of Amplify. Push Notifications likely won't work on v4.x of Amplify, but if you upgrade to the latest version (v5.3.10) that should help fix things! Once you've upgraded, it wouldn't hurt to also delete your |
I have the same issue when trying it on react-native ios. I'm on latest amplify version (5.3.10), @aws-amplify/rtn-push-notification (1.1.6) and react-native (0.71.1). Following this guide: https://docs.amplify.aws/lib/push-notifications/getting-started/q/platform/react-native I've tried clean installs etc but no luck. Any idea? |
@cwomack I also got a similar problem with Amplify's push notification with React Native and run Android. Android app builds okay but it throws runtime error when loading index.js ERROR [ERROR] 17:20.622 Notifications [Error: Unable to find @aws-amplify/rtn-push-notification. ] OS: macOS 13.5.2 (22G91) @aws-amplify/rtn-push-notification installs successfully but it seems it couldn't initialised at start-up. Tried everything as per the docs: Can you please advise? Thank you! |
Hi, I'm also experiencing this problem using "aws-amplify": "5.3.12" |
Sorry guys, forgot to update here. This error is gone and Amplify Push Notification works end-to-end if I start the app from Android Studio (it manages to find @aws-amplify/rtn-push-notification). It's certainly not just my machine or environment as I tried to start fresh with a clean project and other team mates also tried on their dev machines, all facing the same problem, until we launched the app directly from Android Studio (as opposed to |
@mingc I assume the issue in our case is the incompatibility of Expo with Amplfy's push notifications, as I wasn't able to get rid of this error on neither Android nor iOS. |
Wanted to give an update to anyone following this issue and provide some clarity. In v5 of Amplify, it is recommended to use the React Native CLI for Push Notifications due to Expo not being supported out of the box. However, it does appear that in v5 our type is wrong as @simcoder pointed out above and we’ll mark this as a bug. Note, this bug should only be happening when you are attempting to write your own config and calling Amplify.configure(). |
Just wanted to share - Amplify V6 is all good. In case anyone still get stuck on this, probably think about upgrading it. |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Push Notifications
Amplify Categories
notifications
Environment information
Describe the bug
Getting the error
undefined is not an object (evaluating '_awsAmplify.Notifications.Push')
when attempting to importNotifications
fromaws-amplify
despite having followed the steps for setting up push notifications for iOS in React Native according to this link. The error points to a call toNotifications.Push.enable()
.Notifications
also cannot be found innode_modules/aws-amplify/lib-esm/index.d.ts
.Expected behavior
Notifications
is successfully imported and usable.Reproduction steps
npm start --reset-cache
andnpm run ios
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: