aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

Amplify on launch requests permission for notifications in Android, which is undesirable #11562

Closed oscarparedez-eagle closed 1 year ago

oscarparedez-eagle commented 1 year ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Push Notifications

Amplify Categories

notifications

Environment information

System: OS: macOS 13.0 CPU: (12) arm64 Apple M2 Pro Memory: 109.14 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 19.9.0 - ~/.nvm/versions/node/v19.9.0/bin/node npm: 9.6.3 - ~/.nvm/versions/node/v19.9.0/bin/npm Watchman: 2023.06.12.00 - /opt/homebrew/bin/watchman Browsers: Safari: 16.1 npmPackages: @amplitude/analytics-react-native: ^1.1.1 => 1.1.3 @aws-amplify/rtn-push-notification: ^1.1.1 => 1.1.1 @babel/core: ^7.18.0 => 7.21.0 (7.9.0) @babel/plugin-proposal-decorators: 7.18.2 => 7.18.2 @babel/plugin-proposal-optional-catch-binding: 7.16.7 => 7.16.7 (7.18.6) @babel/preset-env: ^7.16.11 => 7.20.2 @babel/runtime: ^7.18.3 => 7.21.0 @datadog/mobile-react-native: ^1.4.0 => 1.4.0 @datadog/mobile-react-navigation: ^1.4.0 => 1.4.0 @expo-google-fonts/inter: ^0.2.2 => 0.2.3 @expo-google-fonts/space-grotesk: ^0.2.2 => 0.2.3 @expo/vector-icons: ^13.0.0 => 13.0.0 @expo/webpack-config: ^0.17.0 => 0.17.4 @julusian/jpeg-turbo: ^2.1.0 => 2.1.0 @react-native-async-storage/async-storage: ^1.18.2 => 1.18.2 @react-native-camera-roll/camera-roll: ^5.3.1 => 5.3.1 @react-native-community/cli-platform-android: ^11.3.3 => 11.3.3 (8.0.5) @react-native-community/cli-platform-ios: ^8.0.2 => 8.0.6 @react-native-community/datetimepicker: ^7.1.0 => 7.1.0 @react-native-community/netinfo: ^9.3.10 => 9.3.10 @react-navigation/bottom-tabs: ^6.3.2 => 6.5.7 @react-navigation/native: ~6.0.1 => 6.0.16 (3.8.4) @react-navigation/native-stack: ^6.0.2 => 6.9.12 @react-navigation/stack: ~6.2.1 => 6.2.3 @rnx-kit/metro-config: ^1.2.32 => 1.3.5 @rnx-kit/metro-resolver-symlinks: 0.1.21 => 0.1.21 @testing-library/jest-dom: ^5.16.5 => 5.16.5 @testing-library/react-native: ^11.4.0 => 11.5.2 @types/i18n-js: 3.8.2 => 3.8.2 @types/jest: 26.0.19 => 26.0.19 @types/react: ^17.0.53 => 17.0.53 @types/react-dom: ^18.0.11 => 18.0.11 @types/react-native: ^0.67.19 => 0.67.19 @types/testing-library__jest-dom: ^5.14.5 => 5.14.5 @typescript-eslint/eslint-plugin: ^5.45.1 => 5.54.0 @typescript-eslint/parser: 5.28.0 => 5.28.0 FreeraspReactNativeExample: 0.0.1 HelloWorld: 0.0.1 amazon-cognito-identity-js: ^6.3.1 => 6.3.1 amazon-cognito-identity-js/internals: undefined () apisauce: 2.1.5 => 2.1.5 aws-amplify: ^5.3.3 => 5.3.3 babel-jest: 26.6.3 => 26.6.3 babel-loader: 8.2.5 => 8.2.5 (8.1.0) date-fns: ^2.29.2 => 2.29.3 deprecated-react-native-prop-types: ^4.0.0 => 4.0.0 (2.3.0) eslint: ^8.29.0 => 8.35.0 eslint-config-prettier: ^8.5.0 => 8.6.0 eslint-config-standard: 17.0.0 => 17.0.0 eslint-config-standard-with-typescript: ^23.0.0 => 23.0.0 eslint-plugin-import: ^2.26.0 => 2.27.5 eslint-plugin-n: ^15.6.0 => 15.6.1 eslint-plugin-node: 11.1.0 => 11.1.0 eslint-plugin-prettier: ^4.2.1 => 4.2.1 eslint-plugin-promise: ^6.1.1 => 6.1.1 eslint-plugin-react: ^7.31.11 => 7.32.2 eslint-plugin-react-native: 4.0.0 => 4.0.0 expo: ~46.0.16 => 46.0.20 expo-application: ~4.2.2 => 4.2.2 expo-clipboard: ~3.1.0 => 3.1.0 expo-constants: ~13.2.3 => 13.2.4 expo-contacts: ~10.3.0 => 10.3.0 expo-device: ~4.3.0 => 4.3.0 expo-file-system: ~14.1.0 => 14.1.0 expo-font: ~10.2.0 => 10.2.1 expo-localization: 13.1.0 => 13.1.0 expo-modules-autolinking: 0.10.1 => 0.10.1 (0.10.3) expo-modules-core: ~0.11.3 => 0.11.10 expo-secure-store: ^12.0.0 => 12.1.1 expo-splash-screen: ~0.16.1 => 0.16.2 expo-status-bar: ~1.4.0 => 1.4.4 fbjs-scripts: 3.0.1 => 3.0.1 freerasp-react-native: ^2.0.3 => 2.0.3 hermes-inspector-msggen: 1.0.0 husky: ^8.0.3 => 8.0.3 i18n-js: 3.9.2 => 3.9.2 jail-monkey: ^2.8.0 => 2.8.0 jest: ^26.6.3 => 26.6.3 jest-circus: 26 => 26.6.3 jest-environment-node: 26 => 26.6.2 jest-expo: ^46.0.1 => 46.0.2 jest-launchdarkly-mock: ^2.0.3 => 2.0.3 jwt-decode: ^3.1.2 => 3.1.2 (2.2.0) launchdarkly-react-client-sdk: ^3.0.6 => 3.0.6 launchdarkly-react-native-client-sdk: ^7.1.4 => 7.1.4 lint-staged: ^13.2.2 => 13.2.2 metro-config: 0.71.1 => 0.71.1 (0.70.3) metro-react-native-babel-preset: 0.71.1 => 0.71.1 (0.70.3, 0.72.3) metro-source-map: 0.71.1 => 0.71.1 (0.70.3) mobx: 6.6.0 => 6.6.0 mobx-react-lite: 3.4.0 => 3.4.0 mobx-state-tree: 5.1.5 => 5.1.5 mocha: 6 => 6.2.3 moment: ^2.29.4 => 2.29.4 moment-timezone: ^0.5.43 => 0.5.43 patch-package: 6.4.7 => 6.4.7 postinstall-prepare: 1.0.1 => 1.0.1 prettier: ^2.8.1 => 2.8.4 query-string: ^7.0.1 => 7.1.3 (6.14.1, 6.10.1) react: 18.0.0 => 18.0.0 react-devtools-core: 4.24.7 => 4.24.7 (4.24.0) react-dom: 18.0.0 => 18.0.0 react-native: 0.69.7 => 0.69.7 react-native-auth0: ^2.16.0 => 2.17.1 react-native-bootsplash: 4.3.2 => 4.3.2 react-native-camera: ^4.2.1 => 4.2.1 react-native-device-info: ^10.3.0 => 10.4.0 react-native-dropdown-picker: ^5.4.6 => 5.4.6 react-native-element-dropdown: ^2.9.0 => 2.9.0 react-native-event-bus: ^1.0.0 => 1.0.0 react-native-event-listeners: ^1.0.7 => 1.0.7 react-native-gesture-handler: ~2.5.0 => 2.5.0 react-native-get-random-values: ^1.9.0 => 1.9.0 react-native-hash: ^3.0.3 => 3.0.3 react-native-hyperlink: ^0.0.22 => 0.0.22 react-native-keyboard-aware-scroll-view: ^0.9.5 => 0.9.5 react-native-keys: ^0.5.2 => 0.5.3 react-native-mask-text: ^0.13.1 => 0.13.1 react-native-paper: ^5.7.0 => 5.7.0 react-native-permissions: ^3.8.0 => 3.8.0 react-native-push-notification: ^8.1.1 => 8.1.1 react-native-qrcode-scanner: ^1.5.5 => 1.5.5 react-native-qrcode-svg: ^6.2.0 => undefined (6.2.0, ) react-native-reanimated: ~2.9.1 => 2.9.1 react-native-responsive-screen: ^1.4.2 => 1.4.2 react-native-safe-area-context: 4.3.4 => 4.3.4 react-native-screens: 3.15.0 => 3.15.0 react-native-selphi-face-plugin: file:facephi/react-native-selphi-face-plugin => 1.1.20 react-native-selphid-plugin: file:facephi/react-native-selphid-plugin => 1.3.26 react-native-share: ^8.2.2 => 8.2.2 react-native-svg: ^13.9.0 => 13.9.0 react-native-svg-transformer: ^1.0.0 => 1.0.0 react-native-url-polyfill: ^1.3.0 => 1.3.0 react-native-vector-icons: ^9.2.0 => 9.2.0 react-native-version-number: ^0.3.6 => 0.3.6 react-native-view-shot: ^3.5.0 => 3.5.0 react-native-virtual-keyboard: ^1.2.2 => 1.2.2 react-native-web: ^0.18.7 => 0.18.12 react-native-zendesk-messaging: ^0.1.0 => 0.1.0 react-navigation: ^4.4.4 => 4.4.4 reactotron-core-client: ^2.8.10 => 2.8.10 (2.8.9) reactotron-mst: 3.1.4 => 3.1.4 reactotron-react-js: ^3.3.7 => 3.3.8 reactotron-react-native: 5.0.3 => 5.0.3 regenerator-runtime: ^0.13.4 => 0.13.11 responsive-screen: 0.1.0 responsive-screen-orientation-change: 0.1.0 responsive-screen-styled-components: 0.1.0 rn-fetch-blob: ^0.12.0 => 0.12.0 steplix-emvqr: file:@steplix-emvqr => 0.2.3 totp-generator: ^0.0.14 => 0.0.14 ts-jest: 26 => 26.5.6 typescript: 4.7.3 => 4.7.3 validator: ^13.9.0 => 13.9.0 webpack: 4 => 4.46.0 (4.43.0) webpack-dev-server: ^3 => 3.11.3 (3.11.0) npmGlobalPackages: corepack: 0.17.1 npm: 9.6.3

Describe the bug

As soon as the app launches, the request permissions for push notifications modal is showing up. The library should be flexible enough so that this can be configured.

Expected behavior

I would like to configure this, like telling the config (probably in aws-exports) to not ask for permissions on app launch. I would like to do so after the user aunthenticates, reaches Home Screen, etc.

Reproduction steps

  1. Amplify.configure(awsconfig)
  2. Notifications.Push.enable()
  3. App launches
  4. Push notifications request permissions is triggered

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

/ eslint-disable / // WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = { aws_project_region: "us-east-1", aws_cognito_identity_pool_id: "xxxx", aws_cognito_region: "xxx", oauth: {}, aws_cognito_username_attributes: [], aws_cognito_social_providers: [], aws_cognito_signup_attributes: [], aws_cognito_mfa_types: [], aws_cognito_password_protection_settings: { passwordPolicyCharacters: [], }, aws_cognito_verification_mechanisms: [], aws_mobile_analytics_app_id: "xxxx", aws_mobile_analytics_app_region: "xxx", Analytics: { AWSPinpoint: { appId: "xxxxx", region: "xxx", }, }, Notifications: { Push: { AWSPinpoint: { appId: "xxxx", region: "us-east-1", }, }, }, }

export default awsmobile

Manual configuration

No response

Additional configuration

No response

Mobile Device

Android Pixel 5

Mobile Operating System

API 33

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

cwomack commented 1 year ago

Hello, @oscarparedez-eagle 👋 and thanks for opening this issue. For Android versions lower than v13, the permission modal pops upon channel creation and happens at startup by default. However, v13+ of Android will allow for control of when the permissions modal pops up via the Notifications.Push.getPermissionStatus() method. So the time at which the permissions modal will appear is going to be based on your app's target SDK version.

Can you confirm what version of Android you're currently on?

ParkAward commented 1 year ago

@cwomack Looking at AWS Pinpoint, I could send a test message only if I had an fcm token, but I can't send a version android 12?, is it only possible to send segments?

What should i do if I want fcm token?

cwomack commented 1 year ago

Hey, @ParkAward. Does that mean you're currently using Android v12.x? Just to confirm, have you already gone through the steps to set up FCM for Push Notifications within your app?

cwomack commented 1 year ago

Closing this issue since we haven't heard and the documentation was updated to provide a better callout for this. If there's further questions or a need to reopen this issue, please feel free to reply back!