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

Pinpoint, cannot send email and notifications to user #8753

Closed paulsjohnson91 closed 1 year ago

paulsjohnson91 commented 3 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Analytics

Amplify Categories

analytics

Environment information

``` npmPackages: @aws-amplify/analytics: ^5.0.6 => 5.0.6 @aws-amplify/api: ^4.0.6 => 4.0.6 @aws-amplify/auth: ^4.1.2 => 4.1.2 @babel/core: ^7.8.4 => 7.11.6 (7.8.7, 7.13.14, 7.9.6) @babel/runtime: ^7.8.4 => 7.8.7 (7.11.0, 7.9.2) @invertase/react-native-apple-authentication: ^1.1.2 => 1.1.2 @react-native-async-storage/async-storage: ^1.15.5 => 1.15.5 @react-native-community/datetimepicker: ^3.4.7 => 3.4.7 @react-native-community/eslint-config: ^1.1.0 => 1.1.0 @react-native-community/google-signin: ^4.0.3 => 4.0.3 @react-native-community/masked-view: ^0.1.10 => 0.1.10 @react-native-community/netinfo: ^5.9.1 => 5.9.1 @react-native-community/push-notification-ios: ^1.8.0 => 1.8.0 @react-native-community/toolbar-android: ^0.1.0-rc.2 => 0.1.0-rc.2 @react-native-firebase/analytics: ^10.8.1 => 10.8.1 @react-native-firebase/app: 10.8.1 => 10.8.1 @react-native-firebase/messaging: 10.8.1 => 10.8.1 @react-navigation/bottom-tabs: 5.11.11 => 5.11.11 @react-navigation/native: 5.9.4 => 5.9.4 @react-navigation/stack: 5.14.5 => 5.14.5 Example: 0.0.1 HelloWorld: 0.0.1 amazon-cognito-identity-js: ^5.0.5 => 5.0.5 aws-amplify: ^4.2.0 => 4.2.0 aws-amplify-react-native: ^5.0.3 => 5.0.3 babel-jest: ^25.1.0 => 25.5.1 (26.0.1) crypto-js: 3.3.0 => 3.3.0 eslint: ^6.8.0 => 6.8.0 fuse.js: ^6.4.0 => 6.4.0 fuzzy: ^0.1.3 => 0.1.3 fuzzy-search: ^3.2.1 => 3.2.1 hermes-inspector-msggen: 1.0.0 jest: ^26.0.1 => 26.0.1 metro-react-native-babel-preset: ^0.59.0 => 0.59.0 (0.58.0) moment: ^2.24.0 => 2.24.0 prop-types: ^15.7.2 => 15.7.2 (15.6.2) react: 16.13.1 => 16.13.1 react-animated: 0.1.0 react-native: 0.63.3 => 0.63.3 react-native-app-intro-slider: ^4.0.4 => 4.0.4 react-native-background-timer: 2.2.0 => 2.2.0 react-native-calendars: ^1.1129.0 => 1.1129.0 react-native-camera: ^3.26.0 => 3.26.0 react-native-collapsible: ^1.5.2 => 1.5.2 react-native-config: ^1.2.0 => 1.2.0 react-native-deep-linking: ^2.2.0 => 2.2.0 react-native-dialog: ^5.6.0 => 5.6.0 react-native-elements: ^2.0.0 => 2.0.0 react-native-fast-image: ^8.1.5 => 8.1.5 react-native-fbsdk: ^2.0.0 => 2.0.0 react-native-floating-action: https://github.com/ramonvermeulen/react-native-floating-action.git#fixForNativeDriverWarning => 1.20.0 react-native-floating-label: ^0.2.3 => 0.2.3 react-native-gesture-handler: ^1.6.1 => 1.6.1 react-native-inappbrowser-reborn: ^3.6.3 => 3.6.3 react-native-iphone-x-helper: ^1.2.1 => 1.2.1 (1.3.1) react-native-keychain: ^6.0.0 => 6.0.0 react-native-linear-gradient: ^2.5.6 => 2.5.6 react-native-modal-datetime-picker: ^9.2.1 => 9.2.1 react-native-modest-checkbox: ^3.3.0 => 3.3.0 react-native-popup-menu: ^0.15.7 => 0.15.7 react-native-push-notification: ^7.4.0 => 7.4.0 react-native-reanimated: ^1.9.0 => 1.9.0 react-native-safe-area-context: ^3.2.0 => 3.2.0 react-native-screens: ^2.8.0 => 2.8.0 react-native-share: ^3.3.2 => 3.3.2 react-native-side-drawer: ^1.2.6 => 1.2.6 react-native-simple-toast: ^1.1.2 => 1.1.2 react-native-size-matters: ^0.4.0 => 0.4.0 react-native-snap-carousel: 3.9.1 => 3.9.1 react-native-spinkit: ^1.5.0 => 1.5.0 react-native-splash-screen: ^3.2.0 => 3.2.0 react-native-svg: ^12.1.0 => 12.1.0 react-native-svg-transformer: ^0.14.3 => 0.14.3 react-native-tab-view: ^2.14.2 => 2.14.2 react-native-vector-icons: ^6.6.0 => 6.6.0 react-native-view-shot: ^3.1.2 => 3.1.2 react-native-walkthrough-tooltip: ^1.1.9 => 1.1.9 react-redux: ^7.2.0 => 7.2.0 react-test-renderer: 16.13.1 => 16.13.1 redux: ^4.0.5 => 4.0.5 redux-persist: ^6.0.0 => 6.0.0 redux-persist/integration/react: undefined () redux-saga: ^1.1.3 => 1.1.3 redux-saga/effects: undefined () redux-thunk: ^2.3.0 => 2.3.0 tcomb-form-native: ^0.6.20 => 0.6.20 url-parse: ^1.4.7 => 1.4.7 npmGlobalPackages: npm: 7.19.1 ```

Describe the bug

Following the developers guide for pinpoint setup with amplify, it doesn't appear that cognito integration is working properly. Although I am getting analytics through, all endpoints are coming through as ineligible, and if I try to manually set them to eligible, I can only use one channel type at a time.

Expected behavior

I should be able to send emails and notifications to my users.

Reproduction steps

Link cognito to pinpoint Screenshot 2021-08-13 at 16 11 53

Enable analytics in your project

  const analyticsConfig = {
    AWSPinpoint: {
      // Amazon Pinpoint App Client ID
      appId: '<id>',
      // Amazon service region
      region: 'eu-west-1',
      mandatorySignIn: false,
    },
  };
 Analytics.configure(analyticsConfig);

At this point I can see my endpoints being populated in pinpoint, but they are all ineligible (except for two manual), Screenshot 2021-08-13 at 16 15 17

To make these endpoints eligible you need to add

optOut: 'NONE'

If you try to add this to the initial config

const analyticsConfig = {
    AWSPinpoint: {
      // Amazon Pinpoint App Client ID
      appId: '<id>',
      // Amazon service region
      region: 'eu-west-1',
      mandatorySignIn: false,
      endpoint :{
          optOut: 'NONE'
      }
    },
  }

Then the code complains because the address is missing. So here is the main problem, at this point whether I set the channel type to EMAIL or GCM (both of which I need) I need to provide the address, being either the users email or the users firebase token. I'm not sure why this is the case for the email because I have integrated cognito into pinpoint. If I have the users userId, I should be able to email that user from the test messaging section of pinpoint but it doesn't work because when I do a get users endpoints request, none exist for that userid unless I add them manually using the updateEndpoint function.

  let endpoint = {
    optOut: 'NONE',
    channelType: 'EMAIL',
    attributes: {
      ...attr
    },
    address: email,
    UserId: username,
  };
  await Analytics.updateEndpoint(endpoint);

The other issue here is that there is only an updateEndpoint function, and there seems to be no way to set up two endpoints for a user, so I can either have a user with email, or with firebase notifications enabled, but not both.

Code Snippet

No response

Log output

No response

aws-exports.js

const authConfig = {
  userPoolId: '<id>',
  userPoolWebClientId: '<client>',
  identityPoolId: '<poolid>',
  logins: {
    google:
      '<url>',
  },
  region: 'eu-west-1',
  federatedTarget: 'COGNITO_USER_POOLS',
  authenticationFlowType: 'USER_PASSWORD_AUTH',
  oauth: {
    options: {
      urlOpener: async (url, redirectSignIn) => {
        await InAppBrowser.isAvailable();
        console.log(url);
        const response = await InAppBrowser.openAuth(
          url,
          redirectSignIn ? redirectSignIn : '<url>',
          {
            dismissButtonStyle: 'cancel',
            showTitle: false,
            enableUrlBarHiding: true,
            enableDefaultShare: false,
          },
        );
        if (response.type === 'cancel') {
          <go to sign in>
        } else if (response.type === 'success' && response.url) {
          <go to home>
        }
      },
    },
    domain: '<domain>',
    scope: [
      'phone',
      'email',
      'profile',
      'openid',
      'aws.cognito.signin.user.admin',
    ],
    redirectSignIn: '<url>',
    redirectSignOut: '<url>',
    responseType: 'code',
  },
}

Manual configuration

No response

Additional configuration

{
    "UserPool": {
        "Id": "<id>",
        "Name": "<name>",
        "Policies": {
            "PasswordPolicy": {
                "MinimumLength": 8,
                "RequireUppercase": false,
                "RequireLowercase": false,
                "RequireNumbers": false,
                "RequireSymbols": false,
                "TemporaryPasswordValidityDays": 7
            }
        },
        "LambdaConfig": {
            "PostConfirmation": "<lambda>",
            "UserMigration": "<lambda>"
        },
        "LastModifiedDate": "2021-07-26T11:49:57.157000+01:00",
        "CreationDate": "2020-08-07T11:58:27.016000+01:00",
        "SchemaAttributes": [
            {
                "Name": "sub",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": false,
                "Required": true,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "given_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": true,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

paulsjohnson91 commented 3 years ago

Hi, is there any update on this? It's been a few weeks

biller-aivy commented 2 years ago

@chrisbonifacio any update here?

tannerabread commented 2 years ago

@paulsjohnson91 @biller-aivy Are either of you still experiencing this issue?

biller-aivy commented 2 years ago

@paulsjohnson91 @biller-aivy

Are either of you still experiencing this issue?

I created a Lambada with the pinpoint sdk and manage this by myself now.

cwomack commented 1 year ago

@paulsjohnson91, I wanted to follow up to see you're still experiencing issues with trying to send email/notifications to users or if you've found a workaround by now. There's a few topics covered in this issue that I'll try to delineate and see if there's better assistance we can provide... or possibly absorb the topics into related issues.

Apologies on a delayed response, but looking forward to unblocking you (if still an issue) and getting more context if possible!

cwomack commented 1 year ago

Closing this issue as we have not heard back from you. Please review the comment above and provide any information/responses previously requested and we'd be happy to re-open this issue. For updates on the feature request to permit multiple endpoints to be updated simultaneously, follow issue #6289.

Thank you!