@ReactMethod public void initCredentialsProvider(String identityPoolId, String token, String region) { RegionUtils regionUtils = new RegionUtils(); Region awsRegion = regionUtils.getRegion(region); cognitoCredentialsProvider = new CognitoCachingCredentialsProvider( mActivityContext.getApplicationContext(), identityPoolId, // awsRegion); Regions.EU_WEST_1); cognitoClient = new CognitoSyncManager( mActivityContext.getApplicationContext(), // awsRegion, Regions.EU_WEST_1, cognitoCredentialsProvider); }
private AWSMobileClient(final Context context, final String cognitoIdentityPoolID, final Regions cognitoRegion, final String mobileAnalyticsAppID, final IdentityManager identityManager, final ClientConfiguration clientConfiguration) { this.context = context; this.identityManager = identityManager; this.clientConfiguration = clientConfiguration; try { this.mobileAnalyticsManager = MobileAnalyticsManager. getOrCreateInstance(context, AWSConfiguration.AMAZON_MOBILE_ANALYTICS_APP_ID, AWSConfiguration.AMAZON_MOBILE_ANALYTICS_REGION, identityManager.getCredentialsProvider(), new AnalyticsConfig(clientConfiguration)); } catch (final InitializationException ie) { Log.e(LOG_TAG, "Unable to initalize Amazon Mobile Analytics. " + ie.getMessage(), ie); } this.syncManager = new CognitoSyncManager(context, AWSConfiguration.AMAZON_COGNITO_REGION, identityManager.getCredentialsProvider(), clientConfiguration); this.dynamoDBClient = new AmazonDynamoDBClient(identityManager.getCredentialsProvider(), clientConfiguration); this.dynamoDBMapper = new DynamoDBMapper(dynamoDBClient); }
public static void init(Context context) { provider = new CognitoCachingCredentialsProvider(context, AWS_ACCOUNT_ID, COGNITO_POOL_ID, COGNTIO_ROLE_UNAUTH, COGNITO_ROLE_AUTH, Regions.US_EAST_1); //initialize the clients cognitosync = new CognitoSyncManager(context, Regions.US_EAST_1, provider); manager = new TransferManager(provider); ddb = new AmazonDynamoDBClient(provider); //ddbmapper = new DynamoDBMapper(ddb); analytics = MobileAnalyticsManager.getOrCreateInstance(context, MOBILE_ANALYTICS_APP_ID, Regions.US_EAST_1, provider); kinesis = new KinesisRecorder(context.getDir(KINESIS_DIRECTORY_NAME, 0), Regions.US_EAST_1, provider); lambda = new LambdaInvokerFactory(context, Regions.US_WEST_2, provider); }
/** * Gets the singleton instance of the CognitoClient. init() must be call * prior to this. * * @return an instance of CognitoClient */ public static CognitoSyncManager getCognitoSync() { if (cognitosync == null) { throw new IllegalStateException("client not initialized yet"); } return cognitosync; }
/** * Gets the singleton instance of the CognitoClient. init() must be called * prior to this. * * @return an instance of CognitoClient */ public static CognitoSyncManager getInstance() { if (syncClient == null) { throw new IllegalStateException("CognitoSyncClientManager not initialized yet"); } return syncClient; }
/** * Hidden default constructor (singleton) */ private AccountManager() { // Initializing the CredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider ( context, context.getString(R.string.aws_identity_pool), // Identity Pool ID Regions.EU_WEST_1 // Put your own region here ); // Initializing the Sync Manager syncManager = new CognitoSyncManager( context, Regions.EU_WEST_1, credentialsProvider); dataset = syncManager.openOrCreateDataset(DATASET_NAME); Log.v(TAG, "Created AccountManager..."); }
/** * Gets the Amazon Cognito Sync Manager, which is responsible for saving and * loading user profile data, such as game state or user settings. * @return sync manager */ public CognitoSyncManager getSyncManager() { return syncManager; }