Open OtayNacef opened 5 months ago
Hello, @OtayNacef 👋. Sorry to hearing you're experiencing this issue. Are you able to share the frontend code that's causing this behavior? And is this on Android emulators or real, physical devices?
Hello, @cwomack. I've conducted testing on an actual Samsung S21+ device. The issue appears exclusively in the internal test and Play Store release, while iOS functions flawlessly on development and production.
App.tsx
Amplify.configure(awsconfig as ResourcesConfig);
useEffect(() => {
Amplify.configure(awsconfig as ResourcesConfig);
const unsubscribe = Hub.listen('auth', async ({payload}) => {
switch (payload.event) {
case 'signInWithRedirect': {
await getUser();
break;
}
}
});
return unsubscribe;
}, [getUser]);
@cwomack added a toast inside hub.listen https://github.com/aws-amplify/amplify-js/assets/46994974/0b061812-af41-4221-839c-0aca534f354c
The problem can be fixed by making sure Hub.listen is set up right in the same part of your code where you handle logins, especially for handling signInWithRedirect events.
@OtayNacef
We are experiencing the same issue. The first login attemp won't trigger the signInWithRedirect
event, while the second attempt does.
Would you please share your solution to this problem?
Our code is very simple as below:
Amplify.configure(amplifyconfig);
export const App = () => {
useEffect(() => {
const unsubscribe = Hub.listen('auth', async ({payload}) => {
switch (payload.event) {
case 'signInWithRedirect':
Alert.alert('success', 'signInWithRedirect');
break;
}
});
return unsubscribe;
}, []);
return (
<SafeAreaProvider>
<ThemeProvider theme={theme}>
<GestureHandlerRootView style={{flex: 1}}>
<LoginScreen />
</GestureHandlerRootView>
</ThemeProvider>
</SafeAreaProvider>
);
};
LoginScreen
only contains a button which triggers signInWithRedirect({provider: 'Google'});
@cwomack We reproduced this issue on Pixel3 and Redmi Note 10T in production mode. Package versions are:
"@aws-amplify/react-native": "^1.1.1",
"@aws-amplify/rtn-web-browser": "^1.0.30",
"aws-amplify": "^6.3.4"
@gokaten-token
try {
await signInWithRedirect(signInInput);
// TODO : TEMP FIX ANDROID BUG Amplify first signin redirect
if (IS_ANDROID && !__DEV__)
setTimeout(async () => {
await signInWithRedirect(signInInput);
}, 1000);
} catch (error) {
Updated this issue to be a bug as we have reproduced it on our side and believe it is related to #13443. Thank you @OtayNacef and @gokaten-token for the additional context!
@cwomack Thanks for the update! We'll keep an eye on issue for any progress. Appreciate the coordination and effort.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Other
Environment information
Describe the bug
After migrating to Amplify v6 and deploying the app on production or internal test , I've encountered an issue with federated login on Android devices with no error returned . The problem occurs only during the initial login attempt with Google authentication. The user needs to sign in twice to be successfully authenticated. Interestingly, this issue is not present in non-production environments, and subsequent login attempts work as expected.
Expected behavior
The expected behavior is that users should be successfully authenticated on the first attempt when signing in with Google
Reproduction steps
Note: This issue is specific to production environments on Android, and subsequent login attempts after the initial occurrence function as expected.
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response