flutter_cognito_plugin 0.0.11 flutter_cognito_plugin: ^0.0.11 copied to clipboard
AWS Cognito plugin for flutter.
Flutter Cognito Plugin #
An AWS Cognito plugin for flutter. Supports both iOS and Android.
Installation #
First follow the regular flutter plugin installation on Dart Pub.
Make sure you have built the app once for both Android/iOS before continuing.
Since this plugin uses the native AWS sdk, the installation is a little more involved.
Android #
Add an awsconfiguration.json
file to android/app/src/main/res/raw/awsconfiguration.json
.
This is typically what one looks like -
{
"Version": "1.0",
"CredentialsProvider": {
"CognitoIdentity": {
"Default": {
"PoolId": "REPLACE_ME",
"Region": "REPLACE_ME"
}
}
},
"IdentityManager": {
"Default": {}
},
"CognitoUserPool": {
"Default": {
"AppClientSecret": "REPLACE_ME",
"AppClientId": "REPLACE_ME",
"PoolId": "REPLACE_ME",
"Region": "REPLACE_ME"
}
}
}
This plugin supports the amplify SDK for android and iOS,
and the the amplify cli can be used to generate the awsconfiguration.json
file.
d
Just do $ amplify init
from the android
& ios
folder of your app.
iOS #
Run $ pod init
from the ios
folder of your app.
Now, open ios/Podfile
. Ensure ios version is set to a minimum of 9.0
.
platform :ios, '9.0'
To add the awsconfiguration.json
file to iOS module, you will unfortunately,
need to open up your project XCode.
You can also do the same thing with JetBrains AppCode, if you prefer.
-
Start Xcode
-
Click on ‘File > Open’
-
Select the
ios/Runner.xcworkspace
file.
Now just drag-drop the awsconfiguration.json
file, from android/app/src/main/res/raw/awsconfiguration.json
to XCode.
Here is a GIF showing how to do this.
That will create a soft link to the file in the ios module, and hopefully bundle it into the final ios app.
This way you won't need to maintain 2 config files.
Usage #
The plugin comes with a showcase app that will let you try all features;
see if you setup the awsconfiguration.json
correctly.
It's present in the usual example
directory
$ git clone https://github.com/pycampers/flutter_cognito_plugin.git
$ cd flutter_cognito_plugin/example
$ flutter run