检查设备通知设置:确保设备通知设置中已经允许AWS SNS发送推送通知。
检查AWS SNS主题策略:确保您的主题策略正确设置,以便接收到的推送通知将被推送到设备。
示例主题策略:
{ "Version" : "2008-10-17", "Statement" : [ { "Effect" : "Allow", "Principal" : "*", "Action" : "SNS:Publish", "Resource" : "arn:aws:sns:us-west-2:123456789012:MyTopic", "Condition" : { "ArnEquals" : { "aws:SourceArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic" } } } ] }
示例代码:
// 处理接收到的推送通知 function handleNotification(notification) { // 将推送通知发送到设备的通知中心 var notificationData = { title: notification.title, message: notification.body, sound: "default", priority: "high", id: notification.messageId, click_action: "FLUTTER_NOTIFICATION_CLICK", }; // 使用插件将推送通知发送到通知中心 flutterLocalNotificationsPlugin.show( notification.messageId, notification.title, notification.body, notificationData, ); }
通过检查设备设置、主题策略和应用程序代码,您应该能够解决AWS SNS不显示推送通知的问题。