ConnectyCube / connectycube-reactnative-samples

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

push notification for android -- video chat #67

Closed tihor123 closed 4 years ago

tihor123 commented 4 years ago

Hello, dear connectycube team. I am not receiving push notification for the opponent. I followed the documentation. I added my firebase server key on connectycube admin portal, then created a subscription for every user. But when ever I am trying to initiate a push notification I am getting the result but the opponent is not getting any notification.

init = () => { //PushNotificationService.Navigation = navigation; const settings = { onRegister: this.subcribeToPushNotification, onNotification: this.onNotification, popInitialNotification: true, requestPermissions: true, }; if (Platform.OS !== "ios") { settings.senderID = "Here i have provided the senderid from firebase project settings"; } else { settings.permissions = { alert: true, badge: true, sound: true, }; } PushNotification.configure(settings); };

subcribeToPushNotification = async (token) => { console.log("token============", token); const currentUser = await User.create().userData(); const userCredentials = { login: currentUser.PhoneNumber, password: currentUser.PhoneNumber, }; const DeviceInfo = getUniqueId(); const params = { notification_channels: Platform.OS === "ios" ? "apns" : "gcm", device: { platform: Platform.OS, udid: DeviceInfo, }, push_token: { environment: "development", //DEV ? "development" : "production", client_identification_sequence: token.token, bundle_identifier: "Here i have provided my package name for android", }, };

ConnectyCube.createSession(userCredentials)
  .then((session) => {
    ConnectyCube.pushnotifications.subscriptions
      .create(params)
      .then((result) => {
        console.log("PushNotificationService - result", result);
      })
      .catch((error) => {
        console.log("PushNotificationService - error", error);
      });
  })
  .catch(() => {
    console.log("error in creating session");
  });

};

onNotification =async(notification)=> { console.log("NOTIFICATION:::::::::::::::::", notification); }

tihor123 commented 4 years ago

const payload = JSON.stringify({ message: "Dr Andrew is calling you", ios_badge: 1, });

    const pushParameters = {
      notification_type: "push",
      user: { ids: [here I provided opponents login id] }, // recipients.
      environment: "development",
      message: ConnectyCube.pushnotifications.base64Encode(payload),
    };
    ConnectyCube.pushnotifications.events
      .create(pushParameters)
      .then((result) => {
        console.log("Startcall result...", result);
      })
      .catch((error) => {
        console.log("Startcall error...", error);
      });
ccvlad commented 4 years ago

Hello, @tihor123 !

Seems you've written correct code. And we hope that you've configured the react-native-push-notification.

Please check few things:

  1. The receiver subscribed on Push Notifications
  2. You added API KEY for "development" environment in your ConnectyCube admin panel (_admin.connectycube.com/apps/{some_appid}/service/push-notifications/settings)

Will be helpful if you will attach your logs from the sender side (request and response after ConnectyCube.pushnotifications.events.create() call). Also you are able to debug Push Notification via the AndroidStudio on the receiver side.

tihor123 commented 4 years ago

request = {"notification_type":"push","user":{"ids":[1292602]},"environment":"development","message":"eyJtZXNzYWdlIjoiQWxpY2UgaXMgY2FsbGluZyB5b3UiLCJpb3NfYmFkZ2UiOjF9"}

response = [{"event":{"id":299096,"event_type":"one_shot","message":"data.message=QWxpY2UraXMrY2FsbGluZyt5b3U=","date":null,"period":null,"name":null,"occured_count":0,"created_at":"2020-04-28T19:55:22Z","updated_at":"2020-04-28T19:55:22Z","end_date":null,"active":true,"application_id":2063,"user_id":1292609,"kind":"ChatAlert","environment":"development","tag_query":null,"notification_channel":{"name":"gcm"}}}]

On Tue, Apr 28, 2020 at 8:31 PM rohit singh rohitipu944@gmail.com wrote:

On Tue, Apr 28, 2020 at 3:19 PM ccvlad notifications@github.com wrote:

Hello, @tihor123 https://github.com/tihor123 !

Seems you've written correct code. And we hope that you've configured the react-native-push-notification https://github.com/zo0r/react-native-push-notification.

Please check few things:

  1. The receiver subscribed on Push Notifications
  2. You added API KEY for "development" environment in your ConnectyCube admin panel (admin.connectycube.com/apps/{some_app_id}/service/push-notifications/settings http://admin.connectycube.com/apps/%7Bsome_app_id%7D/service/push-notifications/settings )

Will be helpful if you will attach your logs from the sender side (request and response after ConnectyCube.pushnotifications.events.create() call). Also you are able to debug Push Notification via the AndroidStudio on the receiver side.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/67#issuecomment-620500363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJRDGZKHM6DSFOZ5U7VRV3TRO2RBBANCNFSM4MSSRA2Q .

ccvlad commented 4 years ago

The response is successful. Did you configure the react-native-push-notification for Android? Any reaction in logs on the receiver side after push notification was sent (*AndroidStudio debug is more informative)?

ccvlad commented 4 years ago

Closed due to inactivity, please re-open if the issue is still persists