amplify-flutter
amplify-flutter copied to clipboard
AmplifyPushNotificationsPinpoint doesn't support offline configuration
Description
AmplifyPushNotificationsPinpoint
doesn't support offline configuration, so in this case, Amplify can't be configured at all (See steps).
Actual behavior:
PushNotificationException {
"message": "Error occurred awaiting for device token to register device with Pinpoint",
"recoverySuggestion": "Please review the underlying exception",
"underlyingException": "NetworkException {\n \"message\": \"The request failed due to a network error.\",\n \"recoverySuggestion\": \"Ensure that you have an active network connection\",\n \"underlyingException\": \"POST https://cognito-identity.eu-central-1.amazonaws.com/? failed: SocketException: Failed host lookup: 'cognito-identity.eu-central-1.amazonaws.com' (OS Error: No address associated with hostname, errno = 7)\"\n}"
}
#0 AmplifyPushNotifications._registerDevice (package:amplify_push_notifications/src/amplify_push_notifications_impl.dart:403:7)
<asynchronous suspension>
#1 AmplifyPushNotifications._registerDeviceWhenConfigure (package:amplify_push_notifications/src/amplify_push_notifications_impl.dart:348:7)
<asynchronous suspension>
#2 AmplifyPushNotifications.configure (package:amplify_push_notifications/src/amplify_push_notifications_impl.dart:231:5)
<asynchronous suspension>
#3 Future.wait.<anonymous closure> (dart:async/future.dart:518:21)
<asynchronous suspension>
#4 AmplifyClass._configurePlugins (package:amplify_core/src/amplify_class.dart:171:7)
<asynchronous suspension>
#5 AmplifyClass.configure (package:amplify_core/src/amplify_class.dart:128:7)
<asynchronous suspension>
Categories
- [X] Notifications (Push)
Steps to Reproduce
- Disable internet
- Launch a mobile app
- Configure Amplify in
main()
:
await Amplify.addPlugins([
AmplifyAuthCognito(),
AmplifyPushNotificationsPinpoint(),
]);
await Amplify.configure(config.amplify);
runApp(...)
Expected
The Pinpoint plugin will send the device token, etc. when connected to the internet.
Actual
Unconfigured Amplify and no way to continue working with this. Why did you do it this way? This request is not critical, send the device token as fire-and-forget and log errors, then in the listener send it again when it has been updated.
Also as you can see:
https://github.com/aws-amplify/amplify-flutter/blob/17fc13c8afc12c798816150e1005f0e35de56cbf/packages/notifications/push/amplify_push_notifications/lib/src/amplify_push_notifications_impl.dart#L231-L232
Exception in _registerDeviceWhenConfigure
blocks all next steps:
- SDK can't subscribe
- SDK can't be reconfigured
Screenshots
No response
Platforms
- [X] iOS
- [X] Android
Flutter Version
3.19.4
Amplify Flutter Version
1.7.0
Deployment Method
Amplify CLI
Schema
No response
Hi @wcoder, thanks for taking the time to raise this issue. We willl investigate how to better support offline configuring of push notifications.
Can you provide more context for the use case this would unblock you from?
@Equartey use case is simple:
- Imagine an application that can work without the internet but using Amplify sometimes
- The user doesn't have internet access.
- For some reason, the app was restarted (due to a phone reboot or another issue).
- The app cannot configure Amplify at launch because the Pinpoint plugin blocks everything.
@wcoder thanks for the info. We have labeled this as bug and will let you know when we have an update on a fix.
This was resolved in version 2.2.0. If you are still facing issue after upgrading please let us know. Thanks.