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

Android version can't setup/use AmplifyPushNotificationsPinpoint() plugin #5384

Open
2 of 14 tasks
marcuscheung-carbonlinking opened this issue Aug 28, 2024 · 12 comments
Open
2 of 14 tasks
Labels
push notifications question A question about the Amplify Flutter libraries

Comments

@marcuscheung-carbonlinking
Copy link

marcuscheung-carbonlinking commented Aug 28, 2024

Description

ios version is ok,
android version work before,
my flutter version: 3.24.0.

this my amplify configure method:

Future<void> _configureAmplify() async {
  try {
    final authPlugin = AmplifyAuthCognito();
    final notificationsPlugin = AmplifyPushNotificationsPinpoint();
    notificationsPlugin
        .onNotificationReceivedInBackground(myAsyncNotificationReceivedHandler);

    await Amplify.addPlugins([
      authPlugin,
      notificationsPlugin,
      AmplifyAPI(modelProvider: ModelProvider.instance),
      AmplifyStorageS3(),
    ]);
    await Amplify.configure(amplifyconfig);
  } on Exception catch (e) {
    safePrint('An error occurred configuring Amplify: $e');
  }
}

this the error message:

 An error occurred configuring Amplify: PushNotificationException {
 "message": "Error occurred awaiting for device token to register device with Pinpoint",
 "recoverySuggestion": "Please review the underlying exception",
"underlyingException": "UnknownException {\n  \"message\": \"Forbidden from accessing the Pinpoint resource.\",\n  \"recoverySuggestion\": \"Please ensure Analytics is properly configured in your amplifyconfiguration.dart file and that unauthenticated guest access is allowed or an authorized user is signed in.\",\n  \"underlyingException\": \"ForbiddenException {\\n}\"\n}"
}

my amplify package version:
amplify_flutter: ^1.8.0
amplify_api: ^1.8.0
amplify_auth_cognito: ^1.8.0
amplify_core: ^1.8.0
amplify_storage_s3: ^1.8.0
amplify_push_notifications_pinpoint: ^1.8.0

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

launch the flutter project with android device and use AmplifyPushNotificationsPinpoint plugin

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.24.0

Amplify Flutter Version

1.8.0

Deployment Method

Amplify CLI (Gen 1)

Schema

No response

@github-actions github-actions bot added pending-triage This issue is in the backlog of issues to triage pending-maintainer-response Pending response from a maintainer of this repository labels Aug 28, 2024
@Jordan-Nelson
Copy link
Member

Hello @marcuscheung-carbonlinking - Do you know what changes were made between the time when this was working to when it stopped working? Did you upgrade flutter, are you testing on a new device, were there code changes?

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Aug 28, 2024
@Jordan-Nelson Jordan-Nelson added pending-community-response Pending response from the issue opener or other community members push notifications labels Aug 28, 2024
@marcuscheung-carbonlinking
Copy link
Author

i just have one android device for testing.
i did upgraded flutter version from 3.19.6 to 3.24.0, but i also try to downgrade/install flutter again.
i'm not sure since when, but we have develop branch for stable version of app, that can't init pinpoint plugin too.

@github-actions github-actions bot added pending-maintainer-response Pending response from a maintainer of this repository and removed pending-community-response Pending response from the issue opener or other community members labels Aug 28, 2024
@Jordan-Nelson
Copy link
Member

Is the user authenticated when this error occurs? Have you configured unauthenticated guest access for pinpoint?

@Jordan-Nelson Jordan-Nelson added pending-community-response Pending response from the issue opener or other community members and removed pending-maintainer-response Pending response from a maintainer of this repository labels Aug 28, 2024
@marcuscheung-carbonlinking
Copy link
Author

i notice the error message has one more line:
INFO | EndpointInfoStoreManager | No EndpointId found, generating a new one.
An error occurred configuring Amplify: PushNotificationException {
"message": "Error occurred awaiting for device token to register device with Pinpoint",
"recoverySuggestion": "Please review the underlying exception",
"underlyingException": "UnknownException {\n "message": "Forbidden from accessing the Pinpoint resource.",\n "recoverySuggestion": "Please ensure Analytics is properly configured in your amplifyconfiguration.dart file and that unauthenticated guest access is allowed or an authorized user is signed in.",\n "underlyingException": "ForbiddenException {\n}"\n}"
}

@github-actions github-actions bot added pending-maintainer-response Pending response from a maintainer of this repository and removed pending-community-response Pending response from the issue opener or other community members labels Aug 29, 2024
@marcuscheung-carbonlinking
Copy link
Author

Is the user authenticated when this error occurs? Have you configured unauthenticated guest access for pinpoint?

backend setting?

@Jordan-Nelson
Copy link
Member

Yes, this would be a setting that would have been enabled when setting up the backend.

@Jordan-Nelson Jordan-Nelson added pending-community-response Pending response from the issue opener or other community members and removed pending-maintainer-response Pending response from a maintainer of this repository labels Aug 29, 2024
@marcuscheung-carbonlinking
Copy link
Author

weird thing, last friday i try to setup another amplify-flutter project for deeper explorer amplify&pinpoint, same setup is work.
and after that, my previous project also work now...
since i explorer amplify in my personal computer, it should not related to cache issue, configuration issue or account issue.
not understand why just work again.

@github-actions github-actions bot added pending-maintainer-response Pending response from a maintainer of this repository and removed pending-community-response Pending response from the issue opener or other community members pending-triage This issue is in the backlog of issues to triage labels Sep 2, 2024
Copy link

github-actions bot commented Sep 2, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@marcuscheung-carbonlinking
Copy link
Author

but test on real device still have that error:
/flutter (16447): An error occurred configuring Amplify: PushNotificationException {
I/flutter (16447): "message": "Error occurred awaiting for device token to register device with Pinpoint",
I/flutter (16447): "recoverySuggestion": "Please review the underlying exception",
I/flutter (16447): "underlyingException": "UnknownException {\n "message": "Forbidden from accessing the Pinpoint resource.",\n "recoverySuggestion": "Please ensure Analytics is properly configured in your amplifyconfiguration.dart file and that unauthenticated guest access is allowed or an authorized user is signed in.",\n "underlyingException": "ForbiddenException {\n}"\n}"

@Jordan-Nelson
Copy link
Member

@marcuscheung-carbonlinking - That error would indicate that there currently is no user logged in and that your pinpoint backend is not setup to allow unauthenticated users. Here are the steps to setup pinpoint with the Gen 1 CLI and enable unauthenticated access: https://docs.amplify.aws/gen1/flutter/build-a-backend/push-notifications/set-up-push-notifications/#set-up-backend-resources

@Jordan-Nelson Jordan-Nelson added question A question about the Amplify Flutter libraries and removed pending-maintainer-response Pending response from a maintainer of this repository labels Sep 3, 2024
@Jordan-Nelson Jordan-Nelson added the pending-community-response Pending response from the issue opener or other community members label Sep 3, 2024
@marcuscheung-carbonlinking
Copy link
Author

marcuscheung-carbonlinking commented Sep 12, 2024

@marcuscheung-carbonlinking - That error would indicate that there currently is no user logged in and that your pinpoint backend is not setup to allow unauthenticated users. Here are the steps to setup pinpoint with the Gen 1 CLI and enable unauthenticated access: https://docs.amplify.aws/gen1/flutter/build-a-backend/push-notifications/set-up-push-notifications/#set-up-backend-resources

i try to install android version flutter app (same code, same build) on sumsung A12 & sony XQ-DC72.A12 works. but XQ-DC72 can't.
both android 14(update to date).

if we upgrade to amplify 2.x, will it fix my issue?

@github-actions github-actions bot added pending-maintainer-response Pending response from a maintainer of this repository and removed pending-community-response Pending response from the issue opener or other community members labels Sep 12, 2024
@tyllark
Copy link
Member

tyllark commented Sep 13, 2024

Hello @marcuscheung-carbonlinking, can you please confirm that you have both authenticated and guest access enabled in Cognito.
AWS Console -> Cognito -> Identity pools -> Identity pool name -> User access

Afterwards can to please confirm that the IAM policies for both are configured per our documentation.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
push notifications question A question about the Amplify Flutter libraries
Projects
None yet
Development

No branches or pull requests

3 participants