-
Notifications
You must be signed in to change notification settings - Fork 266
Closed
Labels
bugSomething is not working; the issue has reproducible steps and has been reproducedSomething is not working; the issue has reproducible steps and has been reproducedpending-releaseIssues that have been addressed in main but have not been releasedIssues that have been addressed in main but have not been releasedpush notifications
Description
Description
I have been following the official documentation to configure both AmplifyAuthCognito and AmplifyPushNotificationsPinpoint for my Flutter app. However, I have encountered an issue where configuring both libraries simultaneously causes the Authenticator to become stuck on the loading screen.
Interestingly, I discovered that when I comment out the line for AmplifyPushNotificationsPinpoint, the app runs without any issues.
Tested only on Android.
I have included the relevant code snippet below for reference:
import 'package:flutter/material.dart';
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_authenticator/amplify_authenticator.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:amplify_push_notifications_pinpoint/amplify_push_notifications_pinpoint.dart';
import 'amplifyconfiguration.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
AmplifyLogger().logLevel = LogLevel.info;
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
_configureAmplify();
}
void _configureAmplify() async {
try {
await Amplify.addPlugins([
AmplifyAnalyticsPinpoint(),
AmplifyAuthCognito(),
// *** Commenting out the following line will cause the app to work as expected. ***
// AmplifyPushNotificationsPinpoint()
]);
await Amplify.configure(amplifyconfig);
} on AmplifyAlreadyConfiguredException {
safePrint(
'Tried to reconfigure Amplify; this can occur when your app restarts on Android.',
);
}
}
@override
Widget build(BuildContext context) {
return Authenticator(
child: MaterialApp(
builder: Authenticator.builder(),
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('You are logged in!'),
ElevatedButton(
onPressed: () async {
await Amplify.Auth.signOut();
},
child: const Text('Sign Out'),
),
],
),
),
),
),
);
}
}
Categories
- Analytics
- API (REST)
- API (GraphQL)
- Auth
- Authenticator
- DataStore
- Storage
Steps to Reproduce
- Create a Flutter app and integrate Amplify-Flutter for both authentication and push notifications.
- Copy the code snippet provided above and paste it into the main.dart file.
- Run the app, and it should work without any issues.
- Close the app.
- Comment out the line of code that configures AmplifyPushNotificationsPinpoint.
- Run the app again, and it gets stuck showing the loading spinner.
Screenshots
Platforms
- iOS
- Android
- Web
- macOS
- Windows
- Linux
Flutter Version
3.7.12
Amplify Flutter Version
1.0.1
Deployment Method
Amplify CLI
Schema
No response
Metadata
Metadata
Assignees
Labels
bugSomething is not working; the issue has reproducible steps and has been reproducedSomething is not working; the issue has reproducible steps and has been reproducedpending-releaseIssues that have been addressed in main but have not been releasedIssues that have been addressed in main but have not been releasedpush notifications