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

Open rate is not counted as 0 in AWS Pinpoint #3139

Closed
OhashiTakuya opened this issue Dec 26, 2022 · 9 comments
Closed

Open rate is not counted as 0 in AWS Pinpoint #3139

OhashiTakuya opened this issue Dec 26, 2022 · 9 comments
Assignees
Labels
bug Something isn't working pending-response Issue is pending response from the issue requestor pinpoint Issues with the AWS Android SDK for Pinpoint.

Comments

@OhashiTakuya
Copy link

State your question
I'm using aws-android-sdk-pinpoint to confirm receipt of push notifications, but the open rate remains 0 even if I open the push notification. Open rates are not documented.

In addition, the following message is displayed when a message is received.

 AmazonClientException: Failed submission of 1 events, events will be removed from the local database. 
    com.amazonaws.AmazonClientException: Cognito Identity not configured

In addition, the following message is displayed when a message is received. Cognito's init is done in the Activity after opening, is it related?

Which AWS Services are you utilizing?
AWS Pinpoint

Provide code snippets (if applicable)

 AmazonClientException: Failed submission of 1 events, events will be removed from the local database. 
    com.amazonaws.AmazonClientException: Cognito Identity not configured

Environment(please complete the following information):

  • 'com.amazonaws:aws-android-sdk-mobile-client:2.54.0'
  • 'com.amazonaws:aws-android-sdk-auth-userpools:2.54.0'
  • 'com.amazonaws:aws-android-sdk-pinpoint:2.54.0'

Device Information (please complete the following information):

  • Device: Galaxy Note8 SC-01K
    • Android Version: 9
  • Device: AQUOS sense6 SH-54B
    • Android Version: 9
@dengdan154 dengdan154 added pinpoint Issues with the AWS Android SDK for Pinpoint. pending-triage Issue is pending triage labels Dec 27, 2022
@sdhuka
Copy link
Contributor

sdhuka commented Jan 10, 2023

@OhashiTakuya Looking at the logs, it seems like notification opened is recorded correctly but not able to sync because Cognito is not configured when events are attempted to submit to Pinpoint. Could you please initialize Cognito in Application class so it is configured correctly when submitevent is called in the activity?

@OhashiTakuya
Copy link
Author

@sdhuka
Thank you for your answer.

I added the following code to the Application Class as you replied, but I still get the same error. Do you need any other code?

AWSMobileClient.getInstance()
                .initialize(applicationContext, awsConfig, object : Callback<UserStateDetails?> {)
                    override fun onError(e: Exception) {
                        Log.e("INIT", "Initialization error." , e)
                    

                    override fun onResult(result: UserStateDetails?>) { {
                        Log.i("INIT", "User state: " + result?.userState)
                    }

                })
```

@eeatonaws eeatonaws added bug Something isn't working and removed pending-triage Issue is pending triage labels Jan 17, 2023
@tjleing
Copy link
Contributor

tjleing commented Jan 19, 2023

Just checking, you're still seeing com.amazonaws.AmazonClientException: Cognito Identity not configured? When you initialize the AWSMobileClient are you seeing Initialization error or a successful initialization with a user state?

@OhashiTakuya
Copy link
Author

@tjleing
I tried initializing the client which successfully ran the onResult function.
Also, the userState returned with the string "SIGN IN" and a token seems to be included in the response.

@tjleing
Copy link
Contributor

tjleing commented Jan 21, 2023

@OhashiTakuya now that you're initializing AWSMobileClient successfully are you still seeing Cognito Identity not configured? I believe that what was originally happening is that the "notification opened" event was not being sent to Pinpoint, so you are getting an open rate of 0.

I was able to open notifications sent via a campaign in Pinpoint and see the open rate increase just fine. Just to be sure, you aren't setting pinpointConfig.withAllowsEventCollection(false), right?

If none of these work, could you try upgrading to SDK version 2.60.0 and also providing a redacted copy of your amplifyconfiguration.json file (likely in res/raw)?

@tjleing
Copy link
Contributor

tjleing commented Jan 21, 2023

Ahh wait I just saw that you mentioned "Cognito's init is done in the Activity after opening, is it related?" -- this is almost certainly the issue; if AWSMobileClient is not initialized by the time the app is opened it will not be able to submit the open event to Pinpoint. You could use the onCreate() of your main activity to do this; if the app is backgrounded it will retain the fact that it was initialized.

@OhashiTakuya
Copy link
Author

@tjleing I am initializing AWSMobileClient inside the getPinpointManager function, and this function is called inside the onCreate method. I have copied the code below. Is there anything that I am doing wrong here?

    override fun onCreate() {
        super.onCreate()
        if (BuildConfig.DEBUG) {
            Timber.plant(Timber.DebugTree())
        }
        AppInjector.init(this)
        getPinpointManager(applicationContext)
    }

    fun getPinpointManager(applicationContext: Context): PinpointManager? {
        if (pinpointManager == null) {
            val awsConfig = AWSConfiguration(applicationContext)
            AWSMobileClient.getInstance()
                .initialize(applicationContext, awsConfig, object : Callback<UserStateDetails?> {
                    override fun onError(e: Exception) {
                        Log.e("INIT", "Initialization error.", e)
                    }

                    override fun onResult(result: UserStateDetails?) {
                        Log.i("INIT", "User State: " + result?.userState)
                    }

                })
            val pinpointConfig = PinpointConfiguration(
                applicationContext,
                AWSMobileClient.getInstance(),
                awsConfig
            )
            pinpointManager = PinpointManager(pinpointConfig)
            FirebaseMessaging.getInstance().token
                .addOnCompleteListener(OnCompleteListener { task ->
                    if (!task.isSuccessful) {
                        Log.w(
                            "SSTAPP",
                            "Fetching FCM registration token failed",
                            task.exception
                        )
                        return@OnCompleteListener
                    }
                    val token: String? = task.result
                    pinpointManager?.notificationClient?.registerDeviceToken(token)
                })
        }
        return pinpointManager
    }

@tjleing
Copy link
Contributor

tjleing commented Jan 26, 2023

@OhashiTakuya looks fine to me, I've been mostly using this sample app here -- did you set up Pinpoint with allowing unauthenticated access? You can check the authenticated and unauthenticated IAM policies in the AWS console to make sure. Then again, that would likely cause a different error. Can you please verify that you are still observing the error that Cognito Identity is not configured?

@tjleing tjleing added the pending-response Issue is pending response from the issue requestor label Feb 2, 2023
@tjleing
Copy link
Contributor

tjleing commented Mar 9, 2023

Closing since we didn't hear back -- please open a new issue if the problem persists.

@tjleing tjleing closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-response Issue is pending response from the issue requestor pinpoint Issues with the AWS Android SDK for Pinpoint.
Projects
None yet
Development

No branches or pull requests

5 participants