urbanairship / airship-flutter

Flutter integration
Other
17 stars 17 forks source link

How to prevent a notification from showing #209

Closed rlee1990 closed 3 months ago

rlee1990 commented 3 months ago

I need help preventing a notification from showing when it is for a call notification. I tried checking for certain data in onPushReceived and displaying the call notification but the Airship notification still shows also.

handleNotificationReceived(PushReceivedEvent event) {
    if (event.pushPayload.extras['messageType'] != null &&
        event.pushPayload.extras['messageType'] == 'videoCall') {
      final data = CallNotificationDataModel.fromJson(
          event.pushPayload.extras['messageData']);
      CallServices().startReceivedCall(data);
      return;
    } else {
      log('Message received: ${event.pushPayload}');
    }
  }
Ulrico972 commented 3 months ago

Hello, I'm not sure to understand why you would want to prevent the display of an Airship notification. Could you give us some more context about your use case please ? Also, have you considered using silent notifications ? https://docs.airship.com/platform/mobile/push/getting-started/?groupid=flutter#silent-notifications

rlee1990 commented 3 months ago

@Ulrico972 so what I want to do is display a call screen when the app is in the foreground or background anytime a notification with a certain data type is received. A silent notification wouldn't work since they are not always delivered.

crow commented 3 months ago

Take a look at custom notification providers on Android and content extensions on iOS