react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
740 stars 284 forks source link

How to prevent Notification from showing if app is in foreground? #250

Open stephanoparaskeva opened 3 years ago

stephanoparaskeva commented 3 years ago

I want to post a notification and have the option to not display said notification if app is in foreground.

my current provider implementation looks like this and ignoreInForeground works on android:

      const payload = JSON.stringify({
        message: x?.data?.message,
        ignoreInForeground: true,
      });
      const pushParameters = {
        notification_type: 'push',
        user: { ids: [recipient.data?.cubeId] }, // recipients.
        environment: __DEV__ ? 'development' : 'production',
        message: ConnectyCube.pushnotifications.base64Encode(payload),
      };
      await ConnectyCube.pushnotifications.events.create(pushParameters);
    };