amazon-archives / amazon-cognito-auth-js

The Amazon Cognito Auth SDK for JavaScript simplifies adding sign-up, sign-in with user profile functionality to web apps.
Apache License 2.0
424 stars 232 forks source link

LaunchUri override is not working on 1.3.2 #191

Open mitsuruog opened 5 years ago

mitsuruog commented 5 years ago

Environment:

I tried to use this project on react-native. and tried to use "LaunchUrl override functionality". My code is something like this:

import { Linking } from 'react-native';
import { CognitoAuth } from 'amazon-cognito-auth-js';

const config = {
    // ... other options here
    LaunchUri: (uri) => Linking.openURL(uri),
};

const client = new CognitoAuth(config);

But, LaunchUrl persists refer to window.open. It seems not working on 1.3.2.

So, I finally found the issue that the /lib folder still refer to 1.3.1. I wonder you just forgot to replace under /lib when publishing 1.3.2...?

Thanks.

schellack commented 5 years ago

I am able to override the LaunchUri with react-native by setting LaunchUri like this:

const config = {
    // ... other options here
    LaunchUri: async url => {
        const result = await WebBrowser.openAuthSessionAsync(url, signInUrl);
        // do stuff with the result
    }

Note that I am using Expo.WebBrowser instead of Expo.Linking so that my app opens a web browser within the app instead of kicking the user out to the device's browser app.