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

Connectycube Push Notification - Not received #222

Closed matrixgourab closed 2 years ago

matrixgourab commented 3 years ago

Hi,

I've added notifications into my app and by following:

Everything looks to work fine, no crashes no error logs. Unfortunately when I send a notification from the dashboard it doesn't appear on my emulator, but if I send one from firebase it works fine. Local notifications also works as expected. It triggers the onNotification function from index.js but doesn't appear (neither in status bar nor as a little top-popup)

`init() { //PushNotificationService.Navigation = navigation; const settings = { onRegister: this.subcribeToPushNotification, onNotification: this.onNotification, popInitialNotification: true, requestPermissions: true, onRegistrationError: function (err) { console.error(err.message, err); } }; if (Platform.OS !== "ios") { settings.senderID = "MY_SENDER_ID"; } else { settings.permissions = { alert: true, badge: true, sound: true, }; }

PushNotification.configure(settings);
PushNotificationIOS.addEventListener('registrationError', (error) => {
  console.log("PushNotificationIOS error", error);
});

PushNotificationIOS.addEventListener('register', (error) => {
  console.log("PushNotificationIOS register", error);
});

PushNotificationIOS.addEventListener('localNotification', (error) => {
  console.log("PushNotificationIOS localNotification", error);
});

PushNotificationIOS.addEventListener('notification', (error) => {
  console.log("PushNotificationIOS notification", error);
});

}

async subcribeToPushNotification(token) { const DeviceInfo = require("react-native-device-info").default; const params = { notification_channels: Platform.OS === "ios" ? "apns" : "gcm", device: { platform: Platform.OS, udid: DeviceInfo.getUniqueId(), }, push_token: { environment: DEV ? "development" : "production", client_identification_sequence: token.token, bundle_identifier: "com.kayanhealth.mobile" }, };

ConnectyCube.pushnotifications.subscriptions
  .create(params)
  .then(result => {
    console.log("PushNotificationService - result", result);
    AsyncStorage.setItem(
      PushNotificationService.DEVICE_TOKEN_KEY,
      `${result[0].subscription.id}`,
    );
  })
  .catch(error => {
    console.log("PushNotificationService - error", error);
  });

}

async onNotification(notification) { console.log("NOTIFICATION: ", notification); let dialogId = null; if (Platform.OS === "ios") { dialogId = notification.data.dialog_id; } else { dialogId = notification.dialog_id; } if ( notification.userInteraction && dialogId !== PushNotificationService.getSelectedDialog() ) { const dialog = await PushNotificationService.getDialogById(dialogId); //PushNotificationService.Navigation.push("Chat", {dialog}); } notification.finish(PushNotificationIOS.FetchResult.NoData); }`

What is the problem? Can anyone help me. Thanks in advance.

daoma90 commented 2 years ago

I'm having the same issue where the connecty cub notification is recieved but doesn't show up on the screen or in the notification tray, did you ever figure it out?

joy-mollick commented 2 years ago

I'm having the same issue where the connecty cub notification is recieved but doesn't show up on the screen or in the notification tray, did you ever figure it out?

This is very common issue ,but they are not replying or not fixing these issues !

DaveLomber commented 2 years ago

@daoma90 @joy-mollick the reason of https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/222#issuecomment-878136158 is that ConnectyCUbe sends 'data' notifications and not 'notification', so this is au to developer how to process the payload

Please refer to https://developers.connectycube.com/reactnative/push-notifications?id=receive-push-notifications - here is a callback where the data should come, and then you can call local notification to display https://github.com/zo0r/react-native-push-notification#local-notifications

ccvlad commented 2 years ago

Closed due to inactivity. Please create a new issue if needed.