├── .gitignore
├── LICENSE
├── README.md
├── android
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── morcmarc
│ └── rctcognito
│ ├── ReactCognitoModule.java
│ └── ReactCognitoPackage.java
├── index.js
├── ios
├── RCTCognito.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── marcell.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── marcell.xcuserdatad
│ │ └── xcschemes
│ │ ├── RCTCognito.xcscheme
│ │ └── xcschememanagement.plist
└── RCTCognito
│ ├── RCTCognito.h
│ └── RCTCognito.m
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | .idea
4 | android/build
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Marcell Jusztin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Native : AWS Cognito Module
2 |
3 | **Deprecated! This library is not actively developed. Check out [react-native-aws-cognito-js](http://github.com/AirLabsTeam/react-native-aws-cognito-js) instead.**
4 |
5 | `react-native-cognito` provides a [React Native](http://facebook.github.io/react-native/) module for integrating with [AWS Cognito](https://aws.amazon.com/cognito/).
6 |
7 | **Features currently supported:**
8 |
9 | * [x] dataset:synchronize
10 |
11 | **Roadmap:**
12 |
13 | * [ ] dataset:subscribe
14 | * [ ] dataset:unsubscrib
15 | * [ ] proper callbacks + events
16 | * [ ] promises
17 | * [ ] twitter auth support
18 | * [ ] google auth support
19 | * [ ] custom login support
20 |
21 | ## Supported Identity Providers
22 |
23 | Currently the following identity providers are supported:
24 |
25 | - Facebook
26 |
27 | In development:
28 |
29 | - Twitter
30 | - Google
31 |
32 | ## Requirements
33 |
34 | `react-native-cognito` does not handle authentication with identity providers such as Facebook. You have to use [react-native-facebook-login](https://github.com/magus/react-native-facebook-login) or similar to get a valid access token to use with `react-native-cognito`.
35 |
36 | ### AWS Mobile SDK
37 |
38 | Make sure you install the AWS Mobile SDK. [https://aws.amazon.com/mobile/sdk/](http://docs.aws.amazon.com/mobile/sdkforios/developerguide/setup.html).
39 |
40 | ## Example Usage
41 |
42 | ```es6
43 | import React from 'react-native';
44 | import Cognito from 'react-native-cognito';
45 | import LoginStore from '../stores/LoginStore';
46 |
47 | let region = 'eu-west-1';
48 | let identityPoolId = 'your_cognito_identity_pool_id';
49 |
50 | class Demo extends React.Component {
51 | constructor() {
52 | // Load login credentials from flux store.
53 | this.state = LoginStore.getState();
54 |
55 | // Provide credentials to Cognito.
56 | Cognito.initCredentialsProvider(
57 | identityPoolId,
58 | this.state.credentials.token, // <- Facebook access token
59 | region);
60 |
61 | // Sync data
62 | Cognito.syncData('testDataset', 'hello', 'world', (err) => {
63 | // callback
64 | // handle errors etc
65 | });
66 | }
67 | }
68 | ```
69 |
70 | ## Install -- iOS
71 |
72 | First, install via npm:
73 |
74 | ```
75 | $ npm install --save react-native-cognito
76 | ```
77 |
78 | Add RCTCognito.xcodeproj to Libraries and add libRCTCognito.a to Link Binary With Libraries under Build Phases. More info and screenshots about how to do this is available in the [React Native documentation](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).
79 |
80 | **Next, select RCTCognito.xcodeproj and add your AWS SDK path to Framework Search Paths under Build Settings.**
81 |
82 | ## Install -- Android
83 |
84 | *Disclaimer: experimental i.e., don't use*
85 |
86 | ### Step 1 - Gradle Settings
87 |
88 | Edit `android/settings.gradle` and add the following lines:
89 |
90 | ```
91 | ...
92 | include ':react-native-cognito'
93 | project(':react-native-cognito').projectDir = new File(rootProject.projectDir, '../node-modules/react-native-cognito/android')
94 | ```
95 |
96 | ### Step 2 - Gradle Build
97 |
98 | Edit `android/app/build.gradle`:
99 |
100 | ```
101 | ...
102 | dependencies {
103 | ...
104 | compile project(':react-native-cognito')
105 | }
106 | ```
107 |
108 | ### Step 3 - Register Package
109 |
110 | Edit `android/app/src/main/java/com/myApp/MainActivity.java`.
111 |
112 | ```java
113 | // Import package
114 | import com.morcmarc.rctcognito.ReactCognitoPackage;
115 |
116 | ...
117 |
118 | public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
119 | ...
120 |
121 | // declare package
122 | private ReactCognitoPackage mReactCognitoPackage;
123 |
124 | ...
125 |
126 | @Override
127 | protected void onCreate(Bundle savedInstanceState) {
128 | super.onCreate(savedInstanceState);
129 | mReactRootView = new ReactRootView(this);
130 | ...
131 | // Instantiate package
132 | mReactCognitoPackage = new ReactCognitoPackage(this);
133 | ...
134 | mReactInstanceManager = ReactInstanceManager.builder()
135 | .setApplication(getApplication())
136 | .setBundleAssetName("index.android.bundle")
137 | .setJSMainModuleName("index.android")
138 |
139 | // Register the package
140 | .addPackage(mReactCognitoPackage)
141 |
142 | .setUseDeveloperSupport(BuildConfig.DEBUG)
143 | .setInitialLifecycleState(LifecycleState.RESUMED)
144 | .build();
145 | ...
146 | }
147 | }
148 | ```
149 |
150 | ### Step 4 - Permissions
151 |
152 | You might have to add the following permission to your `AndroidManifest.xml`:
153 |
154 | ```xml
155 |
156 | ```
157 |
158 | ## Contributors
159 |
160 | - [Sunny Gurnani](https://github.com/SunnyGurnani)
161 |
162 | ## License
163 |
164 | This software is licensed under the MIT License.
165 |
166 | React and React Native are BSD licensed. Facebook also provide an additional patent grant.
167 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | }
5 |
6 | dependencies {
7 | classpath 'com.android.tools.build:gradle:1.2.+'
8 | }
9 | }
10 |
11 | apply plugin: 'com.android.library'
12 |
13 | android {
14 | compileSdkVersion 23
15 | buildToolsVersion "23.0.1"
16 |
17 | defaultConfig {
18 | minSdkVersion 16
19 | targetSdkVersion 22
20 | versionCode 1
21 | versionName "1.0"
22 | }
23 | lintOptions {
24 | abortOnError false
25 | }
26 | }
27 |
28 | repositories {
29 | mavenCentral()
30 | }
31 |
32 | dependencies {
33 | compile 'com.facebook.react:react-native:0.14.+'
34 | compile 'com.amazonaws:aws-android-sdk-core:2.+'
35 | compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
36 | }
37 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/java/com/morcmarc/rctcognito/ReactCognitoModule.java:
--------------------------------------------------------------------------------
1 | package com.morcmarc.rctcognito;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.bridge.ReactApplicationContext;
6 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
7 | import com.facebook.react.bridge.ReactMethod;
8 |
9 | import com.amazonaws.auth.CognitoCachingCredentialsProvider;
10 | import com.amazonaws.regions.Region;
11 | import com.amazonaws.regions.Regions;
12 | import com.amazonaws.regions.RegionUtils;
13 | import com.amazonaws.mobileconnectors.cognito.CognitoSyncManager;
14 | import com.amazonaws.mobileconnectors.cognito.Dataset;
15 | import com.amazonaws.mobileconnectors.cognito.DefaultSyncCallback;
16 |
17 | public class ReactCognitoModule extends ReactContextBaseJavaModule
18 | {
19 | private Context mActivityContext;
20 | private CognitoCachingCredentialsProvider cognitoCredentialsProvider;
21 | private CognitoSyncManager cognitoClient;
22 |
23 | public ReactCognitoModule(ReactApplicationContext reactContext, Context activityContext)
24 | {
25 | super(reactContext);
26 | mActivityContext = activityContext;
27 | }
28 |
29 | @Override
30 | public String getName()
31 | {
32 | return "ReactCognito";
33 | }
34 |
35 | @ReactMethod
36 | public void initCredentialsProvider(String identityPoolId, String token, String region)
37 | {
38 | RegionUtils regionUtils = new RegionUtils();
39 | Region awsRegion = regionUtils.getRegion(region);
40 |
41 | cognitoCredentialsProvider = new CognitoCachingCredentialsProvider(
42 | mActivityContext.getApplicationContext(),
43 | identityPoolId,
44 | // awsRegion);
45 | Regions.EU_WEST_1);
46 |
47 | cognitoClient = new CognitoSyncManager(
48 | mActivityContext.getApplicationContext(),
49 | // awsRegion,
50 | Regions.EU_WEST_1,
51 | cognitoCredentialsProvider);
52 | }
53 |
54 | @ReactMethod
55 | public void syncData(String datasetName, String key, String value)
56 | {
57 | Dataset dataset = cognitoClient.openOrCreateDataset(datasetName);
58 | dataset.put(key, value);
59 | dataset.synchronize(new DefaultSyncCallback());
60 | }
61 | }
--------------------------------------------------------------------------------
/android/src/main/java/com/morcmarc/rctcognito/ReactCognitoPackage.java:
--------------------------------------------------------------------------------
1 | package com.morcmarc.rctcognito;
2 |
3 | import android.content.Context;
4 |
5 | import com.facebook.react.ReactPackage;
6 | import com.facebook.react.bridge.JavaScriptModule;
7 | import com.facebook.react.bridge.NativeModule;
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.uimanager.ViewManager;
10 |
11 | import java.util.ArrayList;
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class ReactCognitoPackage implements ReactPackage
16 | {
17 | private Context mContext;
18 |
19 | public ReactCognitoPackage(Context activityContext) {
20 | mContext = activityContext;
21 | }
22 |
23 | @Override
24 | public List createNativeModules(ReactApplicationContext reactContext)
25 | {
26 | List modules = new ArrayList<>();
27 |
28 | modules.add(new ReactCognitoModule(reactContext, mContext));
29 |
30 | return modules;
31 | }
32 |
33 | @Override
34 | public List> createJSModules()
35 | {
36 | return Collections.emptyList();
37 | }
38 |
39 | @Override
40 | public List createViewManagers(ReactApplicationContext reactContext)
41 | {
42 | return Collections.emptyList();
43 | }
44 | }
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var { Cognito } = require('react-native').NativeModules;
4 |
5 | module.exports = Cognito;
--------------------------------------------------------------------------------
/ios/RCTCognito.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | DD62DB9F1C00BCB0007F4D2A /* RCTCognito.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DD62DB9E1C00BCB0007F4D2A /* RCTCognito.h */; };
11 | DD62DBA11C00BCB0007F4D2A /* RCTCognito.m in Sources */ = {isa = PBXBuildFile; fileRef = DD62DBA01C00BCB0007F4D2A /* RCTCognito.m */; };
12 | DD62DBB51C00C319007F4D2A /* AWSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD62DBB01C00C319007F4D2A /* AWSCore.framework */; };
13 | DD62DBB61C00C319007F4D2A /* AWSCognito.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD62DBB31C00C319007F4D2A /* AWSCognito.framework */; };
14 | /* End PBXBuildFile section */
15 |
16 | /* Begin PBXCopyFilesBuildPhase section */
17 | DD62DB991C00BCB0007F4D2A /* CopyFiles */ = {
18 | isa = PBXCopyFilesBuildPhase;
19 | buildActionMask = 2147483647;
20 | dstPath = "include/$(PRODUCT_NAME)";
21 | dstSubfolderSpec = 16;
22 | files = (
23 | DD62DB9F1C00BCB0007F4D2A /* RCTCognito.h in CopyFiles */,
24 | );
25 | runOnlyForDeploymentPostprocessing = 0;
26 | };
27 | /* End PBXCopyFilesBuildPhase section */
28 |
29 | /* Begin PBXFileReference section */
30 | DD62DB9B1C00BCB0007F4D2A /* libRCTCognito.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTCognito.a; sourceTree = BUILT_PRODUCTS_DIR; };
31 | DD62DB9E1C00BCB0007F4D2A /* RCTCognito.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTCognito.h; sourceTree = ""; };
32 | DD62DBA01C00BCB0007F4D2A /* RCTCognito.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTCognito.m; sourceTree = ""; };
33 | DD62DBB01C00C319007F4D2A /* AWSCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AWSCore.framework; path = "../../aws-ios-sdk-2/frameworks/AWSCore.framework"; sourceTree = ""; };
34 | DD62DBB31C00C319007F4D2A /* AWSCognito.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AWSCognito.framework; path = "../../aws-ios-sdk-2/frameworks/extras/AWSCognito.framework"; sourceTree = ""; };
35 | /* End PBXFileReference section */
36 |
37 | /* Begin PBXFrameworksBuildPhase section */
38 | DD62DB981C00BCB0007F4D2A /* Frameworks */ = {
39 | isa = PBXFrameworksBuildPhase;
40 | buildActionMask = 2147483647;
41 | files = (
42 | DD62DBB61C00C319007F4D2A /* AWSCognito.framework in Frameworks */,
43 | DD62DBB51C00C319007F4D2A /* AWSCore.framework in Frameworks */,
44 | );
45 | runOnlyForDeploymentPostprocessing = 0;
46 | };
47 | /* End PBXFrameworksBuildPhase section */
48 |
49 | /* Begin PBXGroup section */
50 | DD62DB921C00BCB0007F4D2A = {
51 | isa = PBXGroup;
52 | children = (
53 | DD62DBB31C00C319007F4D2A /* AWSCognito.framework */,
54 | DD62DBB01C00C319007F4D2A /* AWSCore.framework */,
55 | DD62DB9D1C00BCB0007F4D2A /* RCTCognito */,
56 | DD62DB9C1C00BCB0007F4D2A /* Products */,
57 | );
58 | sourceTree = "";
59 | };
60 | DD62DB9C1C00BCB0007F4D2A /* Products */ = {
61 | isa = PBXGroup;
62 | children = (
63 | DD62DB9B1C00BCB0007F4D2A /* libRCTCognito.a */,
64 | );
65 | name = Products;
66 | sourceTree = "";
67 | };
68 | DD62DB9D1C00BCB0007F4D2A /* RCTCognito */ = {
69 | isa = PBXGroup;
70 | children = (
71 | DD62DB9E1C00BCB0007F4D2A /* RCTCognito.h */,
72 | DD62DBA01C00BCB0007F4D2A /* RCTCognito.m */,
73 | );
74 | path = RCTCognito;
75 | sourceTree = "";
76 | };
77 | /* End PBXGroup section */
78 |
79 | /* Begin PBXNativeTarget section */
80 | DD62DB9A1C00BCB0007F4D2A /* RCTCognito */ = {
81 | isa = PBXNativeTarget;
82 | buildConfigurationList = DD62DBA41C00BCB0007F4D2A /* Build configuration list for PBXNativeTarget "RCTCognito" */;
83 | buildPhases = (
84 | DD62DB971C00BCB0007F4D2A /* Sources */,
85 | DD62DB981C00BCB0007F4D2A /* Frameworks */,
86 | DD62DB991C00BCB0007F4D2A /* CopyFiles */,
87 | );
88 | buildRules = (
89 | );
90 | dependencies = (
91 | );
92 | name = RCTCognito;
93 | productName = RCTCognito;
94 | productReference = DD62DB9B1C00BCB0007F4D2A /* libRCTCognito.a */;
95 | productType = "com.apple.product-type.library.static";
96 | };
97 | /* End PBXNativeTarget section */
98 |
99 | /* Begin PBXProject section */
100 | DD62DB931C00BCB0007F4D2A /* Project object */ = {
101 | isa = PBXProject;
102 | attributes = {
103 | LastUpgradeCheck = 0710;
104 | ORGANIZATIONNAME = "Marcell Jusztin";
105 | TargetAttributes = {
106 | DD62DB9A1C00BCB0007F4D2A = {
107 | CreatedOnToolsVersion = 7.1.1;
108 | };
109 | };
110 | };
111 | buildConfigurationList = DD62DB961C00BCB0007F4D2A /* Build configuration list for PBXProject "RCTCognito" */;
112 | compatibilityVersion = "Xcode 3.2";
113 | developmentRegion = English;
114 | hasScannedForEncodings = 0;
115 | knownRegions = (
116 | en,
117 | );
118 | mainGroup = DD62DB921C00BCB0007F4D2A;
119 | productRefGroup = DD62DB9C1C00BCB0007F4D2A /* Products */;
120 | projectDirPath = "";
121 | projectRoot = "";
122 | targets = (
123 | DD62DB9A1C00BCB0007F4D2A /* RCTCognito */,
124 | );
125 | };
126 | /* End PBXProject section */
127 |
128 | /* Begin PBXSourcesBuildPhase section */
129 | DD62DB971C00BCB0007F4D2A /* Sources */ = {
130 | isa = PBXSourcesBuildPhase;
131 | buildActionMask = 2147483647;
132 | files = (
133 | DD62DBA11C00BCB0007F4D2A /* RCTCognito.m in Sources */,
134 | );
135 | runOnlyForDeploymentPostprocessing = 0;
136 | };
137 | /* End PBXSourcesBuildPhase section */
138 |
139 | /* Begin XCBuildConfiguration section */
140 | DD62DBA21C00BCB0007F4D2A /* Debug */ = {
141 | isa = XCBuildConfiguration;
142 | buildSettings = {
143 | ALWAYS_SEARCH_USER_PATHS = NO;
144 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
145 | CLANG_CXX_LIBRARY = "libc++";
146 | CLANG_ENABLE_MODULES = YES;
147 | CLANG_ENABLE_OBJC_ARC = YES;
148 | CLANG_WARN_BOOL_CONVERSION = YES;
149 | CLANG_WARN_CONSTANT_CONVERSION = YES;
150 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
151 | CLANG_WARN_EMPTY_BODY = YES;
152 | CLANG_WARN_ENUM_CONVERSION = YES;
153 | CLANG_WARN_INT_CONVERSION = YES;
154 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
155 | CLANG_WARN_UNREACHABLE_CODE = YES;
156 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
157 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
158 | COPY_PHASE_STRIP = NO;
159 | DEBUG_INFORMATION_FORMAT = dwarf;
160 | ENABLE_STRICT_OBJC_MSGSEND = YES;
161 | ENABLE_TESTABILITY = YES;
162 | GCC_C_LANGUAGE_STANDARD = gnu99;
163 | GCC_DYNAMIC_NO_PIC = NO;
164 | GCC_NO_COMMON_BLOCKS = YES;
165 | GCC_OPTIMIZATION_LEVEL = 0;
166 | GCC_PREPROCESSOR_DEFINITIONS = (
167 | "DEBUG=1",
168 | "$(inherited)",
169 | );
170 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
171 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
172 | GCC_WARN_UNDECLARED_SELECTOR = YES;
173 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
174 | GCC_WARN_UNUSED_FUNCTION = YES;
175 | GCC_WARN_UNUSED_VARIABLE = YES;
176 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
177 | MTL_ENABLE_DEBUG_INFO = YES;
178 | ONLY_ACTIVE_ARCH = YES;
179 | SDKROOT = iphoneos;
180 | };
181 | name = Debug;
182 | };
183 | DD62DBA31C00BCB0007F4D2A /* Release */ = {
184 | isa = XCBuildConfiguration;
185 | buildSettings = {
186 | ALWAYS_SEARCH_USER_PATHS = NO;
187 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
188 | CLANG_CXX_LIBRARY = "libc++";
189 | CLANG_ENABLE_MODULES = YES;
190 | CLANG_ENABLE_OBJC_ARC = YES;
191 | CLANG_WARN_BOOL_CONVERSION = YES;
192 | CLANG_WARN_CONSTANT_CONVERSION = YES;
193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
194 | CLANG_WARN_EMPTY_BODY = YES;
195 | CLANG_WARN_ENUM_CONVERSION = YES;
196 | CLANG_WARN_INT_CONVERSION = YES;
197 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
198 | CLANG_WARN_UNREACHABLE_CODE = YES;
199 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
200 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
201 | COPY_PHASE_STRIP = NO;
202 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
203 | ENABLE_NS_ASSERTIONS = NO;
204 | ENABLE_STRICT_OBJC_MSGSEND = YES;
205 | GCC_C_LANGUAGE_STANDARD = gnu99;
206 | GCC_NO_COMMON_BLOCKS = YES;
207 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
208 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
209 | GCC_WARN_UNDECLARED_SELECTOR = YES;
210 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
211 | GCC_WARN_UNUSED_FUNCTION = YES;
212 | GCC_WARN_UNUSED_VARIABLE = YES;
213 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
214 | MTL_ENABLE_DEBUG_INFO = NO;
215 | SDKROOT = iphoneos;
216 | VALIDATE_PRODUCT = YES;
217 | };
218 | name = Release;
219 | };
220 | DD62DBA51C00BCB0007F4D2A /* Debug */ = {
221 | isa = XCBuildConfiguration;
222 | buildSettings = {
223 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../../aws-ios-sdk-2/frameworks/**";
224 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React/**";
225 | OTHER_LDFLAGS = "-ObjC";
226 | PRODUCT_NAME = "$(TARGET_NAME)";
227 | SKIP_INSTALL = YES;
228 | };
229 | name = Debug;
230 | };
231 | DD62DBA61C00BCB0007F4D2A /* Release */ = {
232 | isa = XCBuildConfiguration;
233 | buildSettings = {
234 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../../aws-ios-sdk-2/frameworks/**";
235 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React";
236 | OTHER_LDFLAGS = "-ObjC";
237 | PRODUCT_NAME = "$(TARGET_NAME)";
238 | SKIP_INSTALL = YES;
239 | };
240 | name = Release;
241 | };
242 | /* End XCBuildConfiguration section */
243 |
244 | /* Begin XCConfigurationList section */
245 | DD62DB961C00BCB0007F4D2A /* Build configuration list for PBXProject "RCTCognito" */ = {
246 | isa = XCConfigurationList;
247 | buildConfigurations = (
248 | DD62DBA21C00BCB0007F4D2A /* Debug */,
249 | DD62DBA31C00BCB0007F4D2A /* Release */,
250 | );
251 | defaultConfigurationIsVisible = 0;
252 | defaultConfigurationName = Release;
253 | };
254 | DD62DBA41C00BCB0007F4D2A /* Build configuration list for PBXNativeTarget "RCTCognito" */ = {
255 | isa = XCConfigurationList;
256 | buildConfigurations = (
257 | DD62DBA51C00BCB0007F4D2A /* Debug */,
258 | DD62DBA61C00BCB0007F4D2A /* Release */,
259 | );
260 | defaultConfigurationIsVisible = 0;
261 | defaultConfigurationName = Release;
262 | };
263 | /* End XCConfigurationList section */
264 | };
265 | rootObject = DD62DB931C00BCB0007F4D2A /* Project object */;
266 | }
267 |
--------------------------------------------------------------------------------
/ios/RCTCognito.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/RCTCognito.xcodeproj/project.xcworkspace/xcuserdata/marcell.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/morcmarc/react-native-cognito/33219a4d9fb0d4ad7212a38a891ac8c9d5e737e4/ios/RCTCognito.xcodeproj/project.xcworkspace/xcuserdata/marcell.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/ios/RCTCognito.xcodeproj/xcuserdata/marcell.xcuserdatad/xcschemes/RCTCognito.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/ios/RCTCognito.xcodeproj/xcuserdata/marcell.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | RCTCognito.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | DD62DB9A1C00BCB0007F4D2A
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/ios/RCTCognito/RCTCognito.h:
--------------------------------------------------------------------------------
1 | //
2 | // RCTCognito.h
3 | // RCTCognito
4 | //
5 | // Created by Marcell Jusztin on 21/11/2015.
6 | // Copyright © 2015 Marcell Jusztin. All rights reserved.
7 | //
8 |
9 | #import "RCTBridgeModule.h"
10 | #import "RCTLog.h"
11 | #import
12 | #import
13 |
14 | @interface RCTCognito : NSObject
15 |
16 | - (AWSRegionType)getRegionFromString:(NSString *)region;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/ios/RCTCognito/RCTCognito.m:
--------------------------------------------------------------------------------
1 | //
2 | // RCTCognito.m
3 | // RCTCognito
4 | //
5 | // Created by Marcell Jusztin on 21/11/2015.
6 | // Copyright © 2015 Marcell Jusztin. All rights reserved.
7 | //
8 |
9 | #import "RCTBridge.h"
10 | #import "RCTCognito.h"
11 |
12 | #import
13 | #import
14 |
15 | typedef AWSRegionType (^CaseBlock)();
16 |
17 | @implementation RCTCognito
18 |
19 | @synthesize bridge = _bridge;
20 | RCT_EXPORT_MODULE();
21 |
22 | - (AWSRegionType)getRegionFromString:(NSString *)region {
23 | NSDictionary *regions = @{
24 | @"eu-west-1" : ^{
25 | return AWSRegionEUWest1;
26 | },
27 | @"us-east-1" : ^{
28 | return AWSRegionUSEast1;
29 | },
30 | @"ap-northeast-1" : ^{
31 | return AWSRegionAPNortheast1;
32 | },
33 | };
34 | return ((CaseBlock)regions[region])();
35 | }
36 |
37 | RCT_EXPORT_METHOD(initCredentialsProvider: (NSString *)identityPoolId
38 | : (NSString *)token
39 | : (NSString *)region) {
40 | AWSCognitoCredentialsProvider *credentialsProvider =
41 | [[AWSCognitoCredentialsProvider alloc]
42 | initWithRegionType:[self getRegionFromString:region]
43 | identityPoolId:identityPoolId];
44 |
45 | credentialsProvider.logins = @{
46 | @(AWSCognitoLoginProviderKeyFacebook) : token
47 | };
48 |
49 | AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc]
50 | initWithRegion:[self getRegionFromString:region]
51 | credentialsProvider:credentialsProvider];
52 |
53 | [AWSServiceManager defaultServiceManager].defaultServiceConfiguration =
54 | configuration;
55 | }
56 |
57 | RCT_EXPORT_METHOD(syncData: (NSString *)datasetName
58 | : (NSString *)key
59 | : (NSString *)value
60 | : (RCTResponseSenderBlock)callback) {
61 | AWSCognito *syncClient = [AWSCognito defaultCognito];
62 | AWSCognitoDataset *dataset = [syncClient openOrCreateDataset:datasetName];
63 |
64 | [dataset setString:value forKey:key];
65 | [[dataset synchronize] continueWithBlock:^id(AWSTask *task) {
66 | if (task.error) {
67 | callback(@[ @{@"code":[NSNumber numberWithLong:task.error.code], @"domain":task.error.domain, @"userInfo":task.error.userInfo, @"localizedDescription":task.error.localizedDescription} ]);
68 | } else {
69 | callback(@[ [NSNull null] ]);
70 | }
71 | return nil;
72 | }];
73 | }
74 |
75 | RCT_EXPORT_METHOD(subscribe: (NSString *)datasetName
76 | : (RCTResponseSenderBlock)callback) {
77 | AWSCognito *syncClient = [AWSCognito defaultCognito];
78 | AWSCognitoDataset *dataset = [syncClient openOrCreateDataset:datasetName];
79 |
80 | [[dataset subscribe] continueWithBlock:^id(AWSTask *task) {
81 | if (task.error) {
82 | NSLog(@"Unable to subscribe to dataset");
83 | callback(@[ [task.error localizedDescription] ]);
84 | } else {
85 | NSLog(@"Subscribed to dataset");
86 | callback(@[ [NSNull null] ]);
87 | }
88 | return nil;
89 | }];
90 | }
91 |
92 | @end
93 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-cognito",
3 | "version": "1.3.1-alpha",
4 | "description": "AWS Cognito module for React Native.",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "jest",
8 | "start": ""
9 | },
10 | "private": false,
11 | "repository": {
12 | "type": "git",
13 | "url": "git+ssh://git@github.com/morcmarc/react-native-cognito.git"
14 | },
15 | "keywords": [
16 | "react-native",
17 | "react",
18 | "react-component",
19 | "ios",
20 | "android"
21 | ],
22 | "author": "Marcell Jusztin ",
23 | "license": "MIT",
24 | "bugs": {
25 | "url": "https://github.com/morcmarc/react-native-cognito/issues"
26 | },
27 | "homepage": "https://github.com/morcmarc/react-native-cognito#readme",
28 | "devDependencies": {
29 | "react-native": "^0.14.2"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------