Coder Social home page Coder Social logo

Comments (5)

SwhiteMHC avatar SwhiteMHC commented on June 3, 2024 1

@cwomack Thanks for reaching out. The error is still occurring. As a work around, I am directly importing @react-native-firebase/messaging and making a call to getToken() for the time being.

from amplify-js.

cwomack avatar cwomack commented on June 3, 2024

Hello, @SwhiteMHC. I've got a couple of suggestions to see if we can unblock you here and determine the root cause.
Can you see if moving your token logic to as early in the init process as possible changes the behavior? The token handler should be under just under the initializePushNotifications() call ideally.

Also, the listener.remove() call should be done within the useEffect() hook I believe, otherwise it's being called immediately. Can you see if making this change also helps?

from amplify-js.

SwhiteMHC avatar SwhiteMHC commented on June 3, 2024

Hi @cwomack That worked in the minimally reproducible example. However, I recreated this example app because of an issue with another application. Making this change in the other application does not solve the problem. I have been digging into the code and observe this:

  1. onHostResume() of PushNotificationModule.kt fires and includes a token
  2. sendEvent() of PushNotificationEventManager invokes sendJSEvent(), and includes as the event name 'TokenReceived' and as payload, the mapping {token: "token"}
  3. This event never triggers the onTokenReceived listener from aws-amplify/push-notifications

Interesting enough. I can take the token from the onHostResume() and test the push notification using Amazon Pinpoint Test Messaging, and the device successfully receives the notification.

{
  "name": "com.mhc.appropos",
  "version": "1.9.1",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "test": "jest --verbose && yarn ts-node scripts/regression-ms.ts",
    "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'",
    "build:android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && yarn clean:drawable",
    "clean:drawable": "rm -rf ./android/app/src/main/res/drawable-* && rm -rf ./android/app/src/main/res/raw",
    "postinstall": "yarn run build:ios && yarn run build:android",
    "browser:ios": "cd browserstack/ios && browserstack-node-sdk node test.js --env-file ../../.env",
    "browser:android": "cd browserstack/android && browserstack-node-sdk node test.js --env-file ../../.env"
  },
  "dependencies": {
    "@apollo/client": "3.8.6",
    "@aws-amplify/react-native": "^1.0.28",
    "@aws-amplify/rtn-push-notification": "1.2.5",
    "@aws-amplify/ui-react-native": "2.0.3",
    "@aws-sdk/client-scheduler": "^3.552.0",
    "@expo/metro-config": "^0.10.7",
    "@expo/ngrok": "4.1.0",
    "@jest/globals": "29.7.0",
    "@managedhealth/bac-rn-module": "^1.0.1",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-community/netinfo": "9.3.10",
    "@react-native-community/slider": "4.4.2",
    "@react-native-picker/picker": "2.4.10",
    "@react-navigation/native": "6.1.7",
    "@react-navigation/native-stack": "6.9.13",
    "@testing-library/react": "14.0.0",
    "@testing-library/react-hooks": "8.0.1",
    "@types/cli-progress": "^3.11.5",
    "@types/jest": "29.5.5",
    "@types/node": "^20.11.19",
    "@types/react-native-calendar-picker": "7.0.4",
    "@types/react-native-vector-icons": "6.4.15",
    "apollo-upload-client": "17.0.0",
    "aws-amplify": "6.0.28",
    "browserstack-node-sdk": "^1.32.0",
    "cli-progress": "^3.12.0",
    "clsx": "2.0.0",
    "dotenv": "^16.4.5",
    "expo": "~49.0.15",
    "expo-constants": "14.4.2",
    "expo-dev-client": "~2.4.13",
    "expo-file-system": "~15.4.5",
    "expo-image-manipulator": "~11.3.0",
    "expo-local-authentication": "~13.4.1",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "graphql": "16.8.1",
    "haversine": "1.1.1",
    "mobx": "6.10.2",
    "mobx-react-lite": "4.0.4",
    "mocha": "^10.3.0",
    "moment": "2.29.4",
    "nativewind": "2.0.11",
    "react": "18.2.0",
    "react-hook-form": "7.47.0",
    "react-native": "0.72.10",
    "react-native-blob-util": "^0.19.6",
    "react-native-calendar-picker": "7.1.4",
    "react-native-device-info": "^10.12.0",
    "react-native-dotenv": "3.4.9",
    "react-native-encrypted-storage": "4.0.3",
    "react-native-geocoding": "0.5.0",
    "react-native-geolocation-service": "5.3.1",
    "react-native-get-random-values": "~1.9.0",
    "react-native-keychain": "8.1.2",
    "react-native-maps": "1.7.1",
    "react-native-pdf": "^6.7.4",
    "react-native-permissions": "^4.0.1",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-uuid": "2.0.1",
    "react-native-vector-icons": "10.0.0",
    "react-native-vision-camera": "3.1.0",
    "selenium-webdriver": "4.10.0",
    "util": "0.12.5",
    "webdriverio": "^8.33.1",
    "xlsx": "^0.18.5"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "7.20.0",
    "@faker-js/faker": "^8.4.1",
    "@react-native/eslint-config": "0.72.2",
    "@react-native/metro-config": "0.72.11",
    "@tsconfig/react-native": "3.0.0",
    "@types/apollo-upload-client": "17.0.4",
    "@types/react": "^18.2.48",
    "@types/react-test-renderer": "18.0.0",
    "@types/xlsx": "^0.0.36",
    "babel-jest": "29.2.1",
    "eslint": "8.19.0",
    "metro-react-native-babel-preset": "0.76.8",
    "prettier": "2.4.1",
    "react-test-renderer": "18.2.0",
    "tailwindcss": "3.3.2",
    "ts-node": "^10.9.2",
    "typescript": "4.8.4"
  },
  "private": true,
  "resolutions": {
    "wrap-ansi": "7.0.0",
    "string-width": "4.1.0"
  }
}

Any thoughts?

from amplify-js.

cwomack avatar cwomack commented on June 3, 2024

@SwhiteMHC, are you using Expo Go by chance? And if I'm understanding the above comment properly, it worked in the sample app you provided to make the changes suggested? As for the other application that's experiencing this problem, are you able to share a sample repo or code that can be reviewed there as well?

from amplify-js.

cwomack avatar cwomack commented on June 3, 2024

@SwhiteMHC, wanted to check in and see if you're still experiencing this and saw the questions above.

from amplify-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.