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

Pinpoint push notification registration issue #2557

Closed
1 task done
menan opened this issue Aug 11, 2023 · 8 comments
Closed
1 task done

Pinpoint push notification registration issue #2557

menan opened this issue Aug 11, 2023 · 8 comments
Labels
analytics Related to the Analytics category/plugins not-reproducible Not able to reproduce the issue

Comments

@menan
Copy link

menan commented Aug 11, 2023

Before opening, please confirm:

Language and Async Model

Kotlin

Amplify Categories

Notifications

Gradle script dependencies

// Put output below this line
    implementation("com.amplifyframework:aws-api:2.11.2")
    implementation("com.amplifyframework:aws-auth-cognito:2.11.2")
    implementation("com.amplifyframework:aws-datastore:2.11.2")
    implementation("com.amplifyframework:aws-storage-s3:2.11.2")
    implementation("com.amplifyframework:aws-analytics-pinpoint:2.11.2")
    implementation("com.amplifyframework:aws-push-notifications-pinpoint:2.11.2")

Environment information

# Put output below this line
------------------------------------------------------------
Gradle 8.0
------------------------------------------------------------

Build time:   2023-02-13 13:15:21 UTC
Revision:     62ab9b7c7f884426cf79fbedcf07658b2dbe9e97

Kotlin:       1.8.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          1.8.0_341 (Oracle Corporation 25.341-b10)
OS:           Mac OS X 13.2.1 x86_64


Please include any relevant guides or documentation you're referencing

Push notification registration issue

Describe the bug

Getting the following error when trying to update the pinpoint endpoint

PinpointException occurred during endpoint update: AuthException{message=Failed to get credentials. Check if you are signed in and configured identity pools correctly., cause=null, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
                                                                                                    	at com.amplifyframework.auth.CognitoCredentialsProvider$resolve$2$1.accept(CognitoCredentialsProvider.kt:42)
                                                                                                    	at com.amplifyframework.auth.CognitoCredentialsProvider$resolve$2$1.accept(CognitoCredentialsProvider.kt:37)
                                                                                                    	at com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin$fetchAuthSession$2.invokeSuspend(AWSCognitoAuthPlugin.kt:426)
                                                                                                    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

Reproduction steps (if applicable)

  1. Install the app
  2. Login to Cognito
  3. Allow notifications permissions
  4. Expect the FCM token to be updated on pinpoint

Code Snippet

// Put your code below this line.
    <service android:name="com.amplifyframework.pushnotifications.pinpoint.FCMPushNotificationService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

Log output

// Put your logs below this line


amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@tylerjroach
Copy link
Member

This failure is at Amplify.Auth.fetchAuthSession() which Pinpoint will call to grab credentials. You do not appear to be logged in as expected. Can you please manually call fetchAuthSession while adding AndroidLoggingPlugin(LogLevel.VERBOSE) as the first plugin to be configured in your Amplify configure block?

@tylerjroach tylerjroach added the auth Related to the Auth category/plugins label Aug 11, 2023
@menan
Copy link
Author

menan commented Aug 12, 2023

@tylerjroach thanks for your response. I am already doing Amplify.Auth.fetchAuthSession() and waiting for a successful response before making these calls.

Attached the log file you requested for all amplify logging:
android.log

One thing that stands out for me is java.io.FileNotFoundException: can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_key_keyset__ does not exist not sure if that would be related though

@tylerjroach tylerjroach added the analytics Related to the Analytics category/plugins label Aug 14, 2023
@tjleing
Copy link
Contributor

tjleing commented Aug 15, 2023

@menan: I built an application to reproduce this scenario. What I'm seeing locally is: initially, before Amplify.Auth.signIn(user, pass) is called, the updateEndpointProfile call that happens when the Pinpoint plugin gets configured initially doesn't go through due to this error. Also, if there are events in the queue (Amplify.Analytics.recordEvent(...)), they will fail repeatedly on a timer.

However, when Amplify.Auth.signIn() is called, the events go through and also update the endpoint profile. You can also manually trigger an endpoint profile update by calling Amplify.Notifications.Push.identifyUser or Amplify.Analytics.identifyUser().

How are you signing in in your app? Are you seeing this behavior on your end?

@tjleing tjleing added the pending-community-response Issue is pending response from the issue requestor label Aug 15, 2023
@menan
Copy link
Author

menan commented Aug 15, 2023

It does get called and I am getting Endpoint updated successfully log when I call Amplify.Notifications.Push.identifyUser right after the user logs into the app. But when I try to send a test notification to that userId that I identified earlier, it never is registered there. I can see the audience size is 0 for that userId on Amplify Pinpoint dashboard.

Could there be some sort of permission issue?

@tjleing
Copy link
Contributor

tjleing commented Aug 21, 2023

That's possible -- can you also take note of the FCM token and send a Pinpoint test notification? Alternatively, can you check not just specifically for that userId on the dashboard but to a global segment instead?

@menan
Copy link
Author

menan commented Aug 23, 2023

@tjleing I did try that and the notification is received on the device successfully when I try with the FCM token directly. It's just that I am having issues associating the userId with that token on the pinpoint side. Is there anything that could prevent it? or any way to troubleshoot this? I checked IAM permissions for adding new endpoints and that's also enabled.

@gpanshu gpanshu removed the pending-community-response Issue is pending response from the issue requestor label Oct 13, 2023
@tjleing
Copy link
Contributor

tjleing commented Oct 23, 2023

Hello @menan -- I still can't reproduce your issue. Can you verify how you're creating the segment in Pinpoint? I needed to import a CSV of user IDs in order to filter by user IDs. Also, you can set a breakpoint in TargetingClient.kt executeUpdate() to see the exact request the library is sending to Pinpoint, so that you can verify that the endpoint request includes the correct user with the correct userId.

@gpanshu gpanshu added not-reproducible Not able to reproduce the issue and removed auth Related to the Auth category/plugins labels Oct 24, 2023
@tjleing tjleing closed this as completed Feb 8, 2024
Copy link
Contributor

github-actions bot commented Feb 8, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analytics Related to the Analytics category/plugins not-reproducible Not able to reproduce the issue
Projects
None yet
Development

No branches or pull requests

4 participants