AWS Amplify Push Notifications


First time on your forums, so if I’m in the wrong place please let me know.

I’m working on getting AWS Amplify Push Notifications set up in my Expo project. I’ve followed the documentation on AWS and at this expo blog. I’ve been able to send analytics data to the AWS Pinpoint dashboard so I know I’m configured correctly, but whenever I try to use the PushNotification library I get an Unhandled Promise rejection warning.

The research I’ve done is pointing to a build.gradle problem, but I’m not wanting to eject my project if I can help it.

Here are the build dependencies I have set up currently:

“dependencies”: {
@aws-amplify/pushnotification”: “^1.0.27”,
“aws-amplify”: “^1.1.28”,
“aws-amplify-react-native”: “^2.1.12”,
“aws-sdk”: “^2.457.0”,
“expo”: “^32.0.0”,
“expokit”: “^32.1.2”,
“firebase”: “^6.0.2”,
“fsevents”: “^2.0.6”,
“react”: “^16.5.0”,
“react-native”: “”,
“react-native-push-notification”: “^3.1.3”,
“react-navigation”: “^3.8.1”

Here is the error message:

[Unhandled promise rejection: TypeError: undefined is not an object (evaluating ‘RNPushNotification.initialize’)]

  • node_modules/@aws-amplify/pushnotification/lib/PushNotification.js:139:43 in
  • node_modules/@aws-amplify/pushnotification/lib/PushNotification.js:44:27 in step
  • node_modules/@aws-amplify/pushnotification/lib/PushNotification.js:19:13 in
  • node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
  • node_modules/promise/setimmediate/core.js:200:23 in doResolve
  • node_modules/promise/setimmediate/core.js:66:12 in Promise
  • node_modules/@aws-amplify/pushnotification/lib/PushNotification.js:15:36 in
  • node_modules/@aws-amplify/pushnotification/lib/PushNotification.js:91:12 in configure
  • node_modules/@aws-amplify/core/lib/Amplify.js:25:27 in
  • [native code]:null in map
  • node_modules/@aws-amplify/core/lib/Amplify.js:24:29 in configure
  • App.js:9:18 in
  • node_modules/metro/src/lib/polyfills/require.js:292:12 in loadModuleImplementation
  • node_modules/expo/AppEntry.js:2:0 in
  • node_modules/metro/src/lib/polyfills/require.js:292:12 in loadModuleImplementation
  • node_modules/metro/src/lib/polyfills/require.js:179:45 in guardedLoadModule
  • null:null in global code

I would try using the Expo Push Notification library, but I have a client requirement to use AWS Pinpoint and AWS Push Notifications.

I’ve been banging my head against the wall on these dependencies for a few days now. Any help would be greatly appreciated.


Hi @grant.uland! Sorry you’re having trouble with notifications

Is this in a bare Expo project? I can try on my end to see if I have the same issue, just need all the steps you took :+1:

Also- have you checked the solutions posted here already?

Hi @charliecruzan,

Yes I saw that post a few days ago. Unfortunately, that solution requires android gradle files which I don’t have in my project.

When I ran expo init I chose the blank project template so that’s where I’m starting from.

The application is meant to be a Poc so it’s very minimal. The following is my current project structure

|- App.js
|- app.json
|- aws-exports.js
|- babel.config.js
|- package-lock.json
|- package.json
|- google-services.json
|- /assets
|- /app
| . |- /components
| . | . |- Home.component.js
| . | . |- Notification.component.js
| . |- /routes
| . | . |- index.js

So there really isn’t much to it. The following are all of the steps I’ve done to get PushNotifications set up for the project after the initial project creation

npm install -g @aws-amplify/cli expo-cli
amplify configure
amplify init
npm install -g react
npm install fsevents
npm install --save aws-amplify
react-native link aws-amplify
npm install --save aws-amplify-react-native
react-native link aws-amplify-react-native

After those installs I added the following to our App.js

import Amplify from “aws-amplify”
import config from “./aws-exports”


Then ran expo start and everything works fine.

Next I add analytics to the project as a precursor to PushNotifications

amplify add analytics
amplify push

Which is where the Pinpoint dashboard gets created. I then added the following code to Notification.component.js to test Analytics

import { Button } from ‘react-native’
import Analytics from '@aws-amplify/analytics

onPress = () => { Analytics.record({ name: 'Hello World!'}); }

<Button press={this.onPress} title='Record Event'/> //inside of render

Again, I ran expo start, loaded the app on my phone (Android) and was able to send analytics data to Pinpoint.

So now I start setting up firebase for Android
npm install --save firebase

Added the following to app.json
“ios”: {
“bundleIdentifier”: “com.[company].[appname]”

“android”: {
“package”: “com.[company].[appname]”

Followed the FCM Client Setup instructions here

And then downloaded google-services.json and added
“googleServicesFile”: “./google-services.json”
to app.json and once again test everything with expo start

Finally, I add push notifications

amplify add notifications
amplify push
npm install @aws-amplify/pushnotification --save
react-native link @aws-amplify/pushnotification

And then I add the following to Notification.component.js

import PushNotifiations from ‘@aws-amplify/pushnotification’

PushNotifiations.onNotification((notification) =>
console.log(‘notification received’);

At this point when I run expo start and load the app I get the error mentioned above.

Thanks again for any help. Hopefully I missed something really simple.

Unfortunately, you can’t use native modules in a managed Expo project :confused:

So, good rule of thumb, if you have to run react-native link, you can’t use that package. That would explain why it’s not working.

You’ll either have to eject, or move to the bare workflow to use those packages. Sorry about the confusion!

Hey thanks for the info. I’m a bit confused because according to this post AWS Amplify works with Expo out of the box. I guess that isn’t true for Push Notifications?

I re-tested the above steps without any of the react-native link steps and it all still works up to the point where I get that error message.

Ah okay, so at the time of writing that I believe there was no such thing as Amplify notifications.

I can’t say for sure this wouldn’t work, you could try using the device token (as opposed to Expo token), but you won’t be able to use the Expo Client for testing with this :frowning:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.