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.42k stars 2.12k forks source link

in-app-messaging syncMessages not fetching data locally #12929

Closed pascalito007 closed 5 months ago

pascalito007 commented 8 months ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Analytics, Not applicable

Amplify Version

v6

Amplify Categories

notifications

Backend

None

Environment information

``` System: OS: macOS 14.2.1 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 2.96 GB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.16.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.6.7 - /usr/local/bin/npm Watchman: 2023.11.20.00 - /usr/local/bin/watchman Browsers: Safari: 17.2.1 npmPackages: @aws-amplify/react-native: ^1.0.7 => 1.0.7 @aws-amplify/rtn-web-browser: ^1.0.7 => 1.0.7 @babel/core: ^7.20.0 => 7.22.9 @expo/react-native-action-sheet: ^4.0.1 => 4.0.1 @expo/vector-icons: ^13.0.0 => 13.0.0 @gorhom/bottom-sheet: ^4 => 4.4.7 @react-native-async-storage/async-storage: ^1.21.0 => 1.21.0 @react-native-community/datetimepicker: 7.2.0 => 7.2.0 @react-native-community/netinfo: ^11.2.1 => 11.2.1 @react-native-picker/picker: 2.4.10 => 2.4.10 @react-navigation/bottom-tabs: ^6.5.8 => 6.5.8 @react-navigation/material-top-tabs: ^6.6.4 => 6.6.4 @react-navigation/native: ^6.1.7 => 6.1.7 @react-navigation/native-stack: ^6.9.13 => 6.9.13 @reduxjs/toolkit: ^1.9.5 => 1.9.5 @reduxjs/toolkit-query: 1.0.0 @reduxjs/toolkit-query-react: 1.0.0 @sentry/react-native: 5.10.0 => 5.10.0 HelloWorld: 0.0.1 aws-amplify: ^6.0.12 => 6.0.12 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/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 () date-fns: ^2.30.0 => 2.30.0 expo: ^49.0.21 => 49.0.21 expo-application: ~5.3.0 => 5.3.0 expo-blur: ~12.4.1 => 12.4.1 expo-build-properties: ~0.8.3 => 0.8.3 expo-clipboard: ~4.3.1 => 4.3.1 expo-constants: ~14.4.2 => 14.4.2 expo-dev-client: ~2.4.12 => 2.4.12 expo-device: ~5.4.0 => 5.4.0 expo-font: ~11.4.0 => 11.4.0 expo-image-picker: ~14.3.2 => 14.3.2 expo-location: ~16.1.0 => 16.1.0 expo-notifications: ~0.20.1 => 0.20.1 expo-screen-orientation: ~6.0.6 => 6.0.6 expo-server-sdk: ^3.7.0 => 3.7.0 expo-splash-screen: ~0.20.5 => 0.20.5 expo-status-bar: ~1.6.0 => 1.6.0 expo-system-ui: ~2.4.0 => 2.4.0 expo-task-manager: ~11.3.0 => 11.3.0 expo-tracking-transparency: ~3.1.0 => 3.1.0 expo-updates: ~0.18.17 => 0.18.17 geolib: ^3.3.4 => 3.3.4 nativewind: ^2.0.11 => 2.0.11 react: 18.2.0 => 18.2.0 react-native: 0.72.6 => 0.72.6 react-native-country-picker-modal: ^2.0.0 => 2.0.0 react-native-device-info: ^10.9.0 => 10.9.0 react-native-element-dropdown: ^2.10.0 => 2.10.0 react-native-flash-message: ^0.4.2 => 0.4.2 react-native-geocoding: ^0.5.0 => 0.5.0 react-native-gesture-handler: ~2.12.0 => 2.12.1 react-native-get-random-values: ^1.10.0 => 1.10.0 react-native-gifted-chat: ^2.4.0 => 2.4.0 react-native-google-places-autocomplete: ^2.5.1 => 2.5.6 react-native-image-picker: ^7.0.3 => 7.0.3 react-native-maps: 1.7.1 => 1.7.1 react-native-maps-directions: ^1.9.0 => 1.9.0 react-native-pager-view: 6.2.0 => 6.2.0 react-native-paper: ^5.10.4 => 5.10.4 react-native-phone-number-input: ^2.1.0 => 2.1.0 react-native-reanimated: ~3.3.0 => 3.3.0 react-native-safe-area-context: 4.6.3 => 4.6.3 react-native-screens: ~3.22.0 => 3.22.1 react-native-tab-view: ^3.5.2 => 3.5.2 react-native-uuid: ^2.0.1 => 2.0.1 react-native-webview: 13.2.2 => 13.2.2 react-redux: ^8.1.2 => 8.1.2 redux-persist: ^6.0.0 => 6.0.0 redux-persist/integration/react: undefined () sentry-expo: ~7.1.0 => 7.1.1 tailwindcss: 3.3.2 => 3.3.2 typescript: ^5.1.3 => 5.2.2 use-debounce: ^9.0.4 => 9.0.4 npmGlobalPackages: @angular/cli: 14.2.9 @aws-amplify/cli: 12.3.0 @ionic/cli: 6.20.1 corepack: 0.17.0 create-expo-app: 2.1.1 create-react-app: 3.4.1 csv-to-firestore: 1.0.0 csvtojson: 2.0.10 eas-cli: 7.0.0 firebase-import: 2.2.0 firebase-tools: 8.12.1 ionic: 5.4.16 n: 7.1.0 netlify-cli: 10.7.1 npm-check-updates: 16.10.12 npm: 9.6.7 react-native-cli: 2.0.1 react-native: 0.71.8 serve: 11.3.2 serverless: 3.22.0 ts-node: 10.9.1 yarn: 1.22.19 ```

Describe the bug

I have added and configured In-App-Messaging in my react native expo project but when using await syncMessages(); in my App.js I always got undefined

When I dispatch event with await dispatchEvent({ name: "WelcomePromo" }); I can see that Message Delivered count is increasing in the Pinpoint console but I cant see the In-App-Message

Expected behavior

syncMessages should sync messages locally in order to dispatchEvent to show in-app-message

Reproduction steps

  1. Add and configure Amplify In-App-Messaging
  2. SyncMessage function is not working

Code Snippet

Log output

``` ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

cwomack commented 8 months ago

Hello, @pascalito007 and sorry to hear your running into this. Can you share the frontend code that is calling both syncMessages() as well as dispatchEvent? And just to confirm, are you initializing In-App Messaging in your App.js file right after you call Amplify.configure()?

Thanks and looking forward to helping you get unblocked!

pascalito007 commented 8 months ago

@cwomack thanks for your response. Please find below sample code in my App.js

// At top level
import { useEffect } from "react";
import amplifyconfig from './src/amplifyconfiguration.json';
import { initializeInAppMessaging } from 'aws-amplify/in-app-messaging';
import { syncMessages } from 'aws-amplify/in-app-messaging';

Amplify.configure(amplifyconfig);
initializeInAppMessaging();

export default  App = () => {
      useEffect(() => {
             syncMessages().then((response) => {
               console.log("syncMessages:", response);
             });
           }, []);

}

The console.log response value is always undefined even if I have created a campaign in pinpoint

In a component Home.js When I run below code nothing happen

dispatchEvent({name: "WelcomePromo"});

cwomack commented 6 months ago

@pascalito007, do you see your campaigns getting synched in async storage by chance? The syncMessages() API will not return campaigns when making the call. It will only sync the campaign to the async storage.

As for the UI not displaying, we might need to know more about your setup to understand what's happening there. It doesn't look like you're using the Amplify UI Connected Component for In-App Messaging, but that may be something to consider.

cwomack commented 5 months ago

Closing this issue as we have not heard back from you. If you are still experiencing this, please feel free to reply back and provide any information previously requested and we'd be happy to re-open the issue.

Thank you!