I have been trying to use AWS SDKs for Push Notifications. But I am getting errors. Tried to find a solution, but can't find much support for this.
iOS & Web push notifications are working fine
What all is already setup & done:
- AWS back-end & console setting in place.
- Identity Pool Id & other keys in place.
- ARN topic in place.
Android side:
AWS SDK dependencies:
implementation 'com.amazonaws:aws-android-sdk-core:2.16.8' implementation 'com.amazonaws:aws-android-sdk-cognito:2.6.23' implementation 'com.amazonaws:aws-android-sdk-s3:2.15.1' implementation 'com.amazonaws:aws-android-sdk-ddb:2.2.0' implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.16.8') { transitive = true; }
minSdkVersion 21
targetSdkVersion 29
Inside onCreate:
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider( getApplicationContext(), "My Pool Id here", // Identity pool ID Regions.US_EAST_1 // Region ); CognitoSyncManager client = new CognitoSyncManager( LoginActivateActivity.this, Regions.US_EAST_1, credentialsProvider); String registrationId = "MY_FCM_DEVICE_TOKEN"; **Instead of GCM ID, I am passing my unique FCM device token here. I searched, & it seems that wherever GCM is required, it is being replaced by FCM.** try { client.registerDevice("GCM", registrationId); } catch (RegistrationFailedException rfe) { Log.e("TAG", "Failed to register device for silent sync", rfe); } catch (AmazonClientException ace) { Log.e("TAG", "An unknown error caused registration for silent sync to fail", ace); } Dataset trackedDataset = client.openOrCreateDataset("My Topic here"); if (client.isDeviceRegistered()) { try { trackedDataset.subscribe(); } catch (SubscribeFailedException sfe) { Log.e("TAG", "Failed to subscribe to datasets", sfe); } catch (AmazonClientException ace) { Log.e("TAG", "An unknown error caused the subscription to fail", ace); } }
Error I am getting on client.registerDevice("GCM", registrationId);
Caused by: com.amazonaws.services.cognitosync.model.InvalidConfigurationException: Identity pool isn't set up for SNS (Service: AmazonCognitoSync; Status Code: 400; Error Code: InvalidConfigurationException; Request ID: a858aaa2-**************************)
Note:
I tried using Amplify libraries, but even that didn't work. Also, at iOS & Web end they are using AWS SDK. So I am also bound to use the same. This is not even a device specific error.
All I need to do is setup my project to get push notifications. But I am stuck at the initial step. Not able to create an endpoint for Android device.