Closed Lavanya2204-developer closed 1 year ago
Any update on this? I am facing exact same issue.
Can you please share code snippets and configuration json file with sensitive information removed?
Hi @div5yesh
This is how we initialize the appsync client,
val awsConfig = AWSConfiguration(getJSONObject())
val regions = Regions.fromName(BuildConfig.AWS_REGION)
val cognitoUserPool = CognitoUserPool(mContext.applicationContext, awsConfig)
val basicCognitoUserPoolsAuthProvider = BasicCognitoUserPoolsAuthProvider(cognitoUserPool)
mClient = AWSAppSyncClient.builder()
.context(mContext.applicationContext)
.awsConfiguration(awsConfig)
.cognitoUserPoolsAuthProvider(basicCognitoUserPoolsAuthProvider)
.s3ObjectManager(S3ObjectManagerImplementation(AmazonS3Client(AWSMobileClient.getInstance(), Region.getRegion(regions))))
.build()
And here's how we get the JSONObject
private fun getJSONObject(): JSONObject {
val jsonObject = JSONObject()
// CognitoUserPool
val default = JSONObject()
default.apply {
put("PoolId", mAwsConfig.appSyncConfig?.poolId)
put("AppClientId", mAwsConfig.appSyncConfig?.clientId)
put("Region", BuildConfig.AWS_REGION)
}
val cognitoUserPool = JSONObject()
cognitoUserPool.put("Default", default)
jsonObject.put("CognitoUserPool", cognitoUserPool)
// AppSync
val appSyncDefault = JSONObject()
appSyncDefault.apply {
put("ApiUrl", mAwsConfig.appSyncConfig?.apiUrl)
put("Region", BuildConfig.AWS_REGION)
put("AuthMode", "AMAZON_COGNITO_USER_POOLS")
}
val appSync = JSONObject()
appSync.put("Default", appSyncDefault)
jsonObject.put("AppSync", appSync)
return jsonObject
}
Any update?
@div5yesh Any update on this issue?
@iamfirdous8 are you initializing appsync sdk in the application class?
Yes @poojamat, It's being initialized in the Application class.
@Lavanya2204-developer the log you have provided suggests that mutation queue is dealt with in a background thread what makes you believe its blocking the main thread?
I tried using the latest SDK to implement App Sync but see below logs repeatedly when I run the application. These logs continuously print when the app is freshly installed and seem to block the UI thread as we see a black screen on the activity on which we are subscribing to events. There is no issue on subsequent launch.
Environment:
Device Information:
Additional context FYI, I am trying to subscribe to the App sync client inside
CoroutineScope(Dispatchers.IO)
. We are usingAmazon Cognito UserPools (AMAZON_COGNITO_USER_POOLS)
as the Authentication mode