Skip to content
This repository was archived by the owner on Oct 12, 2018. It is now read-only.

NativeModules.AWSRNCognitoCredentials returns undefined #4

Open
jamespearson opened this issue Sep 2, 2016 · 7 comments
Open

NativeModules.AWSRNCognitoCredentials returns undefined #4

jamespearson opened this issue Sep 2, 2016 · 7 comments

Comments

@jamespearson
Copy link

Trying to use Cognito, and following the example code, I end up with:

import React, {Component} from "react";
import View} from "react-native";

import {AWSCognitoCredentials} from 'aws-sdk-react-native-core';
import {AWSS3TransferUtility} from 'aws-sdk-react-native-transfer-utility';


class Sample extends Component {

    constructor(props) {
        super(props)


        ASCognitoCredentials.initWithOptions({"region": "XXX", "identity_pool_id": "YYY"})
    }

    render() {
        return (<View></View>)
    }
}

XCode produces the following error:

[fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: Cannot read property 'initWithOptions' of undefined

A little debugging, and it appears that in AWSCogniteCredentials.js the following returned: undefined.

var cognitoClient = NativeModules.AWSRNCognitoCredentials;

@michaelcuneo
Copy link

I have the same issue. I responded originally thinking I had fixed it, but I didn't. :(

@appwiz
Copy link
Contributor

appwiz commented Sep 12, 2016

Hi @fearmediocrity @michaelcuneo,

  1. Which version of Xcode are you using?
  2. Did you download the respective framework from the AWS iOS SDK?
  3. What does your header search path look like?

@mnichols
Copy link

@fearmediocrity you are importing AWSCognitoCredentials but are calling ASCognitoCredential which is undefined. (note the missing W)?

@ksegla
Copy link

ksegla commented Oct 17, 2016

I have the same issue. Android. Real device (Samsung S6).
Are there things missing from the README. Do we need to add external libraries (the Android AWS SDK) to make this work? They are mentinoned for iOS but not Android.

@ksegla
Copy link

ksegla commented Oct 17, 2016

This fixed the issue (a bad installation more likely) for Android.
Add this line
compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
in the dependencies of android/app/build.gradle if it's not there.

[How I got there:
I went to my node_modules/aws-sdk-react-native-core/android/build.gradle
saw this:
dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.amazonaws:aws-android-sdk-core:+'
}
From there, I got to this
http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/setup.html

used option 1 (my IDE is not Android Studio but I do use it) and voilà! :)]

@jeffbonasso
Copy link

@appwiz I am having same issue on iOS...
cognitoClient.initWithOptions(options) in AWSCognitoCredentials.js is undefined. Obviously native code not being found. When you say...
Did you download the respective framework from the AWS iOS SDK?
What does your header search path look like?

...can you give a little more detail on how to set those up properly.

I copied appropriate frameworks in iOS/Frameworks in my node_modules and then did xcode build which it said succeeded, but still having this issue. I would assume if build succeeded the header paths are good.

I also found an initial issue in AWSCognitoCredentials.js
it had async {callbackId}, I changed to async (callbackId)

@mnichols
Copy link

Maybe my answer here can help : #24 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants