Description
Description
I'm using Amplify for push notifications. In IOS, when I clicked the push message, it works fine. I can get the push payload i.e.
flutter: 🚀 onNotificationOpened PushNotificationMessage { "title": "Test title", "body": "Test body please ignore", "imageUrl": null, "deeplinkUrl": null, "goToUrl": null, "fcmOptions": null, "apnsOptions": { "subTitle": null }, "data": { "type": "friend_request", "data1": "data21" } }
But when using Android it seems the Amplify.Notifications.Push.onNotificationOpened.listen won't trigger. I just received a message like this
D/AmplifyAuthCognitoPlugin(11095): [onNewIntent] Got intent: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14400000 pkg=au.movinghub.homehub cmp=au.movinghub.homehub/com.example.homehub.MainActivity (has extras) }
D/AmplifyAuthCognitoPlugin(11095): [onNewIntent] Not handling intent
Here is a sample code
Future<void> _configureAmplify() async {
try {
final authPlugin = AmplifyAuthCognito();
final pushPlugin = AmplifyPushNotificationsPinpoint();
pushPlugin.onNotificationReceivedInBackground(myCallback);
if (!Amplify.isConfigured) {
await Amplify.addPlugins([authPlugin, pushPlugin]);
await Amplify.configure(amplifyconfig);
Amplify.Notifications.Push.onTokenReceived.listen((event) {
print('🚀 onTokenReceived $event');
SessionManager().setString("device_id", event.toString());
});
// Required to call this after Amplify.configure.
Amplify.Notifications.Push.onNotificationReceivedInForeground
.listen((event) {
print('🚀 onNotificationReceivedInForeground $event');
});
// Required to call this after Amplify.configure.
// wont trigger in Android
Amplify.Notifications.Push.onNotificationOpened.listen((event) {
print('🚀 onNotificationOpened $event');
print(event.data);
});
}
setState(() {
_amplifyConfigured = true;
});
/*
final subscription = Amplify.Notifications.Push.onNotificationOpened
.listen(myNotificationOpenedHandler);
print(subscription);
*/
} on Exception catch (e) {
print(e.toString());
}
AmplifyLogger().logLevel = LogLevel.info;
}
Im using https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-pinpoint-2016-12-01.html#sendmessages to trigger a push which works fine on both IOS and Android.
Categories
- Analytics
- API (REST)
- API (GraphQL)
- Auth
- Authenticator
- DataStore
- Notifications (Push)
- Storage
Steps to Reproduce
Setup Amplify push notification using Amazon Pinpoint.
Screenshots
No response
Platforms
- iOS
- Android
- Web
- macOS
- Windows
- Linux
Flutter Version
3.24.1
Amplify Flutter Version
2.2.0
Deployment Method
Amplify Gen 2
Schema
No response