Open typefox09 opened 1 year ago
Also, it appears the code below prevents our app from displaying data only notifications when our app is closed as it prevents fireNotification from being called. Why is this?
public void load() {
notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
firebaseMessagingService = new MessagingService();
staticBridge = this.bridge;
if (lastMessage != null) {
fireNotification(lastMessage);
lastMessage = null;
}
notificationChannelManager = new NotificationChannelManager(getActivity(), notificationManager, getConfig());
}
public static void sendRemoteMessage(RemoteMessage remoteMessage) {
PushNotificationsPlugin pushPlugin = PushNotificationsPlugin.getPushNotificationsInstance();
if (pushPlugin != null) {
Log.d("PushNotificationPlugin", "second"); // test to see if called
pushPlugin.fireNotification(remoteMessage);
} else {
lastMessage = remoteMessage;
Log.d("PushNotificationPlugin", "failed"); // test to see if failed
}
}
public static PushNotificationsPlugin getPushNotificationsInstance() {
if (staticBridge != null && staticBridge.getWebView() != null) {
PluginHandle handle = staticBridge.getPlugin("PushNotifications");
if (handle == null) {
return null;
}
return (PushNotificationsPlugin) handle.getInstance();
}
return null;
}
Feature Request
Plugin
Capacitor Push Notifications
Description
Documentation to implement: https://developer.android.com/develop/ui/views/notifications/group
Add functionality to hook into the following 2 lines on the notification builder:
My proposal would be to allow data only notifications for Capacitor's Push Notifications. This would give us the ability to handle the presentation style of notifications. It'd also be great if we could also add actions in the push notifications.
NOTE: I'm aware this functionality is available on local notifications, but this doesn't help when your relying on push (as our app will be closed often). Essentially trying to get a system similar to what Whatsapp, Signal, etc have with their notifications (always displays rich notifications with actions, regardless if in foreground / background or closed).
Platform(s)
iOS (communication notifications - https://developer.apple.com/videos/play/wwdc2021/10091/) Android (Group notifications - https://developer.android.com/develop/ui/views/notifications/group)