ConnectyCube / connectycube-ios-samples

iOS code samples for ConnectyCube platform
https://connectycube.com
Apache License 2.0
2 stars 0 forks source link

Unusual Implementation Strategies for iOS and Flutter Push Notifications #3

Open jostney opened 1 year ago

jostney commented 1 year ago

My question is about ios side of connectycube flutter.

On flutter the whole notification logic is here, push_notifications_manager

For instance, below code scope is where the messages is handled when app is on foreground. But this is NEVER EVER EVER TRIGGERED

FirebaseMessaging.onMessage.listen((remoteMessage) {
  log('[onMessage] message: ${remoteMessage.data}', TAG);
  showNotification(remoteMessage);
});

For instance, below code scope is where the messages is handled when app is on background. But this is NEVER EVER EVER TRIGGERED TOO

FirebaseMessaging.onBackgroundMessage(onBackgroundMessage);

Future<void> onBackgroundMessage(RemoteMessage message) async {
  log('[onBackgroundMessage] message: ${message.data}',
      PushNotificationsManager.TAG);
  showNotification(message);
  return Future.value();
}

The weird thing is, app is able to RECEIVE chat notifications.

Then anyone can ask this: How the app able to receive notifications if those above methods do not work ?

I can easily answer this : I just removed showNotification then archive and sent to test flight. App is still get notifications...

Seems like notifications are handled on native side of ios. Those above methods do not make any sense.

Can anyone comment for this from ios and flutter side of this ? @TatankaConCube @DaveLomber

TatankaConCube commented 1 year ago

@jostney according to the firebase_messaging plugin's documentation, the onMessage stream is the stream that is called when an incoming FCM payload is received whilst the Flutter instance is in the foreground (note FCM). The handler onBackgroundMessage is related to the Android push notifications too.

If you select the alert type for the chat push notifications in the Connectycube admin panel from the iOS settings, the system will automatically show their on the device without developer actions.

Screenshot 2023-02-15 at 14 20 48
jostney commented 1 year ago

For me, the push type option was already set to alert, and chat notifications was received automatically without developer action.

When the push type changed to background, chat notifications are not being received. And all above options(content available, mutable content, use dialog...) were tried with different combinations (single, multi)

Managing how the notifications are handled is important , because we need to customize notifications and group them by conversations.

TatankaConCube commented 1 year ago

please follow the official Apple documentation on how to manage APNS inside your app. As I understand, you can listen to the background push notifications in the didReceiveRemoteNotification callback and do everything you need in your app.

TatankaConCube commented 1 year ago

@jostney try to use the next config USE DIALOG ID AS THREAD-ID in this case the notification should be grouped by the dialog id

Screenshot 2023-02-16 at 18 30 45
jostney commented 1 year ago

If we want to:

Then we need to:

Is this right ?

DaveLomber commented 1 year ago