Skip to content
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

No Credentials Generated for Android Device and No Error #13277

Open
3 tasks done
SwhiteMHC opened this issue Apr 22, 2024 · 3 comments
Open
3 tasks done

No Credentials Generated for Android Device and No Error #13277

SwhiteMHC opened this issue Apr 22, 2024 · 3 comments
Assignees
Labels
pending-response Issue is pending response from the issue requestor Push Notifications Related to Push Notification components question General question React Native React Native related issue

Comments

@SwhiteMHC
Copy link

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Push Notifications

Amplify Version

v6

Amplify Categories

auth, notifications

Backend

Amplify CLI

Environment information

# Put output below this line

 System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 88.13 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.2.4 - /usr/local/bin/npm
    pnpm: 8.15.5 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.62
    Safari: 17.4.1
  npmPackages:
    @aws-amplify/react-native: ^1.0.28 => 1.0.28 
    @aws-amplify/rtn-push-notification: ^1.2.28 => 1.2.28 
    @babel/core: ^7.20.0 => 7.24.4 
    @babel/preset-env: ^7.20.0 => 7.24.4 
    @babel/runtime: ^7.20.0 => 7.24.4 
    @react-native-async-storage/async-storage: ^1.23.1 => 1.23.1 
    @react-native-community/netinfo: ^11.3.1 => 11.3.1 
    @react-native/babel-preset: 0.74.81 => 0.74.81 
    @react-native/eslint-config: 0.74.81 => 0.74.81 
    @react-native/metro-config: 0.74.81 => 0.74.81 
    @react-native/typescript-config: 0.74.81 => 0.74.81 
    @types/react: ^18.2.6 => 18.2.79 
    @types/react-test-renderer: ^18.0.0 => 18.0.7 
    HelloWorld:  0.0.1 
    aws-amplify: ^6.0.28 => 6.0.28 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    babel-jest: ^29.6.3 => 29.7.0 
    eslint: ^8.19.0 => 8.57.0 
    jest: ^29.6.3 => 29.7.0 
    prettier: 2.8.8 => 2.8.8 
    react: 18.2.0 => 18.2.0 
    react-native: 0.74.0 => 0.74.0 
    react-native-dotenv: ^3.4.11 => 3.4.11 
    react-native-get-random-values: ^1.11.0 => 1.11.0 
    react-test-renderer: 18.2.0 => 18.2.0 
    typescript: 5.0.4 => 5.0.4 
  npmGlobalPackages:
    appium: 2.4.1
    corepack: 0.23.0
    eas-cli: 7.6.0
    expo: 50.0.13
    npm: 10.2.4
    pnpm: 8.15.5
    typescript: 5.4.4
    yarn: 1.22.22

Describe the bug

onTokenReceived event, and subsequently the handler, never fires when running on an Android Device.

Expected behavior

onTokenReceivedHandler receives new token, and token is accessible for storage and registration with Amazon Pinpoint.

Reproduction steps

I followed the setup instructions for AWS-Amplify Push Notifications for a completely new React-Native-CLI project: https://docs.amplify.aws/react-native/build-a-backend/push-notifications/set-up-push-notifications/

Minimal Reproducible Example: https://github.com/SwhiteMHC/amplify-fail-android

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

Amplify.configure({
Auth: {
Cognito: {
userPoolId: '',
userPoolClientId: '',
identityPoolId: '',
},
},
Notifications: {
PushNotification: {
Pinpoint: {
appId: '',
region: '',
},
},
},
Analytics: {
Pinpoint: {
appId: '',
region: '',
},
},
});

Additional configuration

{
    "UserPool": {
        "Id": "",
        "Name": "",
        "Policies": {
            "PasswordPolicy": {
                "MinimumLength": 8,
                "RequireUppercase": false,
                "RequireLowercase": false,
                "RequireNumbers": false,
                "RequireSymbols": false,
                "TemporaryPasswordValidityDays": 7
            }
        },
        "DeletionProtection": "ACTIVE",
        "LambdaConfig": {},
        "LastModifiedDate": "2024-04-10T14:18:04.298000-07:00",
        "CreationDate": "2024-02-07T11:03:37.436000-08:00",
        "SchemaAttributes": [
            {
                "Name": "profile",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "address",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "birthdate",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "10",
                    "MaxLength": "10"
                }
            },
            {
                "Name": "gender",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "preferred_username",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "updated_at",
                "AttributeDataType": "Number",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "NumberAttributeConstraints": {
                    "MinValue": "0"
                }
            },
            {
                "Name": "website",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "picture",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "identities",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {}
            },
            {
                "Name": "sub",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": false,
                "Required": true,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "phone_number",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "phone_number_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            {
                "Name": "zoneinfo",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "custom:userId",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "locale",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "email",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": true,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "email_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            {
                "Name": "given_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "family_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "middle_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "nickname",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            }
        ],
        "UsernameAttributes": [
            "email"
        ],
        "EmailVerificationMessage": "Your verification code is {####}",
        "EmailVerificationSubject": "Your verification code",
        "VerificationMessageTemplate": {
            "EmailMessage": "Your verification code is {####}",
            "EmailSubject": "Your verification code",
            "DefaultEmailOption": "CONFIRM_WITH_CODE"
        },
        "UserAttributeUpdateSettings": {
            "AttributesRequireVerificationBeforeUpdate": []
        },
        "MfaConfiguration": "OFF",
        "EstimatedNumberOfUsers": 10,
        "EmailConfiguration": {
            "EmailSendingAccount": "COGNITO_DEFAULT"
        },
        "UserPoolTags": {},
        "AdminCreateUserConfig": {
            "AllowAdminCreateUserOnly": false,
            "UnusedAccountValidityDays": 7
        },
        "UsernameConfiguration": {
            "CaseSensitive": false
        },
        "Arn": "",
        "AccountRecoverySetting": {
            "RecoveryMechanisms": [
                {
                    "Priority": 1,
                    "Name": "verified_email"
                },
                {
                    "Priority": 2,
                    "Name": "verified_phone_number"
                }
            ]
        }
    }
}


Mobile Device

Galaxy A14 5G

Mobile Operating System

Android 14

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

{
  "name": "notificationstest",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@aws-amplify/react-native": "^1.0.28",
    "@aws-amplify/rtn-push-notification": "^1.2.28",
    "@react-native-async-storage/async-storage": "^1.23.1",
    "@react-native-community/netinfo": "^11.3.1",
    "aws-amplify": "^6.0.28",
    "react": "18.2.0",
    "react-native": "0.74.0",
    "react-native-dotenv": "^3.4.11",
    "react-native-get-random-values": "^1.11.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.74.81",
    "@react-native/eslint-config": "0.74.81",
    "@react-native/metro-config": "0.74.81",
    "@react-native/typescript-config": "0.74.81",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

@SwhiteMHC SwhiteMHC added the pending-triage Issue is pending triage label Apr 22, 2024
@cwomack cwomack added the Push Notifications Related to Push Notification components label Apr 22, 2024
@cwomack cwomack self-assigned this Apr 22, 2024
@cwomack cwomack added the React Native React Native related issue label Apr 22, 2024
@cwomack
Copy link
Contributor

cwomack commented Apr 25, 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?

@cwomack cwomack added question General question pending-response Issue is pending response from the issue requestor and removed pending-triage Issue is pending triage labels Apr 25, 2024
@SwhiteMHC
Copy link
Author

SwhiteMHC commented Apr 26, 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?

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue requestor label Apr 26, 2024
@cwomack
Copy link
Contributor

cwomack commented May 2, 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?

@cwomack cwomack added the pending-response Issue is pending response from the issue requestor label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-response Issue is pending response from the issue requestor Push Notifications Related to Push Notification components question General question React Native React Native related issue
Projects
None yet
Development

No branches or pull requests

2 participants