Closed abbas-eno8 closed 2 years ago
It looks like the config you are using does not contain AuthMode
key. Can you share your configuration with sensitive info removed?
@div5yesh We(@abbas-eno8 and I) fixed this issue, by adding aws configuration via code, like below
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
}
So, this issue has been fixed, but after this, we've been facing another issue which has already been raised https://github.com/awslabs/aws-mobile-appsync-sdk-android/issues/350#issuecomment-1056756621
Closing as @iamfirdous8 got it working. Please watch #350 for further updates.
NullPointerException: 'Attempt to invoke virtual method org.json.JSONObject com.amazonaws.mobile.config.AWSConfiguration.optJsonObject(java.lang.String) on a null object reference'
I’m trying to migrate aws-mobile-appsync-sdk-android from 2.9.+ to 3.3.0 as per recommended by AWS for this AWS AppSync APIs v1 protocol (MQTT over WebSockets) will be disabled for all AppSync APIs in favor of v2 protocol (pure WebSockets) mentioned in below to query and receive mutations in real time. https://docs.aws.amazon.com/appsync/latest/devguide/aws-appsync-real-time-data.html
To Reproduce Steps to reproduce the behavior:
Expected behaviour It should subscribe the subscription and execute the callback
Environment:
Device Information
Thanks for your support