ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
124 stars 111 forks source link

How to turn OFF Chat Message Notification when app is closed? #175

Closed stephanoparaskeva closed 3 years ago

stephanoparaskeva commented 3 years ago

My app sends notification with chat message when app is closed. I want to turn this OFF. The reason I want to turn this off is because I am implementing this myself with ConnectyCube.notifications.push instead, so my app sends TWO notifications when app is closed. I want to turn this default behaviour off. This is so I can have the same logic to handle application in background as well. E.g:

    const createMessageReq = async (msg: string) => {
      const x = await cubeWrap(() => ({
        method: 'post',
        url: 'https://api.connectycube.com/chat/Message',
        data: {
          recipient_id: recipient.data?.cubeId,
          type: 3,
          markable: 1,
          message: msg,
          send_to_chat: 1,
        },
      }));

       // Manually send notification on message sent
      const payload = JSON.stringify({
        message: x?.data?.message,
      });
      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);
    };

    const send = useMutation(createMessageReq, {
      // @ts-ignore
      onSuccess: (result: any) => {
        history.refetch();
        queryClient.refetchQueries(DIALOGS_QUERY);
      },
    });

IMG_0372

DaveLomber commented 3 years ago

you can go to Admin panel, Chat page, Offline notifications and disable pushes for offline users when send a chat

Screenshot 2020-12-24 at 16 03 52
stephanoparaskeva commented 3 years ago

you can go to Admin panel, Chat page, Offline notifications and disable pushes for offline users when send a chat

Screenshot 2020-12-24 at 16 03 52

Thank you, this is perfect!