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

After Unsubscribing Device device not gets deleted from Admin Panel. #133

Closed GuleriaAshish closed 3 years ago

GuleriaAshish commented 3 years ago

I have successfully subscribe to push notifications with connectycube. But when i am trying to delete that subscription on logout then the device remains there in the admin panel. It should gets deleted automatically.

Find below the logs for better understanding: [Response][1] {"session": {"application_id": 3448, "created_at": "2020-10-22T05:52:48Z", "id": 18578845, "nonce": 1313, "token": "1e05f67a25a5f227bc65d1a6f9b9b0de33000d78", "ts": 1603345967, "updated_at": "2020-10-22T05:52:48Z", "user": {"avatar": "", "blob_id": null, "created_at": "2020-10-13T14:54:13Z", "custom_data": "", "email": null, "external_user_id": null, "facebook_id": null, "full_name": "Sakshi Banyal", "id": 2192407, "last_request_at": "2020-10-22T05:52:48Z", "login": "Sakshi", "phone": "8216564049", "twitter_id": null, "updated_at": "2020-10-22T05:52:48Z", "user_tags": null, "website": null}, "user_id": 2192407}} [Thu Oct 22 2020 11:22:49.780] LOG [Request][2] POST https://api.connectycube.com/subscriptions.json {"data": {"device": {"platform": "android", "udid": "764822d5338a351b"}, "notification_channel": "gcm", "push_token": {"bundle_identifier": "com.afyanet", "client_identification_sequence": "dqYGBzZ8SRmB5RMDT5TACW:APA91bGlMQZuYmusRgjOaAuP_RMrlnN-5yEF_A96DRnaZ62_lxWhZHR-C49yAR8A64HAQE0o21Cb46xymHCMzzpc4X8SoxzXny8_9S1W_iWjTHIfrArGjfr-vppZIs88rGUfphmuIhrz", "environment": "development"}}, "type": "POST", "url": "https://api.connectycube.com/subscriptions.json"} [Thu Oct 22 2020 11:22:49.950] LOG [Chat] Connect with parameters {"password": "King#123", "userId": 2192407} [Thu Oct 22 2020 11:22:49.970] LOG [Chat] status connecting wss://chat.connectycube.com:5291 [Thu Oct 22 2020 11:22:49.643] LOG [Response][2] [{"subscription": {"device": [Object], "id": 442270, "notification_channel": [Object]}}] [Thu Oct 22 2020 11:22:50.739] LOG [Chat] status connect [Thu Oct 22 2020 11:22:50.741] LOG [Chat] CONNECTING [Thu Oct 22 2020 11:22:50.742] LOG [Chat] status opening [Thu Oct 22 2020 11:22:50.743] LOG [Chat] SENT: [Thu Oct 22 2020 11:22:51.379] LOG [Chat] RECV: [Thu Oct 22 2020 11:22:51.381] LOG [Chat] status open [Thu Oct 22 2020 11:22:51.391] LOG [Chat] RECV: PLAINANONYMOUSPLAIN_FASTzlib</stream:features> [Thu Oct 22 2020 11:22:51.392] LOG [Chat] SENT: ADIxOTI0MDctMzQ0OABLaW5nIzEyMw== [Thu Oct 22 2020 11:22:52.880] LOG [Chat] RECV: [Thu Oct 22 2020 11:22:52.900] LOG [Chat] status opening [Thu Oct 22 2020 11:22:52.910] LOG [Chat] SENT: [Thu Oct 22 2020 11:22:52.763] LOG [Chat] RECV: [Thu Oct 22 2020 11:22:52.765] LOG [Chat] status open [Thu Oct 22 2020 11:22:52.769] LOG [Chat] RECV: zlib</stream:features> [Thu Oct 22 2020 11:22:52.770] LOG [Chat] SENT: [Thu Oct 22 2020 11:22:53.404] LOG [Chat] RECV: jid>2192407-3448@chat.connectycube.com/1204607085-chat-89396</jid [Thu Oct 22 2020 11:22:53.410] LOG [Chat] SENT: [Thu Oct 22 2020 11:22:53.411] LOG [Chat] status online 2192407-3448@chat.connectycube.com/1204607085-chat-89396 [Thu Oct 22 2020 11:22:53.412] LOG [Chat] ONLINE [Thu Oct 22 2020 11:22:53.413] LOG [Chat] CONNECTED [Thu Oct 22 2020 11:22:53.413] LOG [Chat] SENT: [Thu Oct 22 2020 11:22:53.414] LOG [Chat] SENT: [Thu Oct 22 2020 11:22:54.210] LOG [Chat] RECV: [Thu Oct 22 2020 11:22:54.418] LOG [Chat] RECV: [Thu Oct 22 2020 11:22:54.447] LOG [Chat] RECV: [Thu Oct 22 2020 11:23:50.233] WARN deleteSubscription [{"subscription": {"device": [Object], "id": 441382, "notification_channel": [Object]}}] android [Thu Oct 22 2020 11:23:50.235] LOG [Chat] disconnect [Thu Oct 22 2020 11:23:50.240] LOG [Chat] SENT: [Thu Oct 22 2020 11:23:50.240] LOG [Chat] status closing [Thu Oct 22 2020 11:23:50.241] LOG [Request][3] DELETE https://api.connectycube.com/session.json {"dataType": "text", "type": "DELETE", "url": "https://api.connectycube.com/session.json"} [Thu Oct 22 2020 11:23:50.499] LOG [Chat] RECV: [Thu Oct 22 2020 11:23:50.500] LOG [Chat] status close [Thu Oct 22 2020 11:23:50.504] LOG [Chat] status disconnecting [Thu Oct 22 2020 11:23:50.512] LOG [Chat] ERROR: [Error: WebSocket ECONNERROR wss://chat.connectycube.com:5291] [Thu Oct 22 2020 11:23:50.518] LOG [Chat] status disconnect [object Object] [Thu Oct 22 2020 11:23:50.522] LOG [Chat] DISCONNECTED [Thu Oct 22 2020 11:23:50.525] LOG [Chat] status offline [Thu Oct 22 2020 11:23:50.525] LOG [Chat] OFFLINE [Thu Oct 22 2020 11:23:51.611] LOG [Response][3] empty body

@ccvlad Please look into this.

Kachanov-dev commented 3 years ago

Hi @GuleriaAshish. Thank you, it really was a mistake. This is fixed, please update your branch - master.

GuleriaAshish commented 3 years ago

@Kachanov-dev , when did you fixed this? Because i am using the current version of the library and this issue is still there.

Kachanov-dev commented 3 years ago

@GuleriaAshish , you need to make: git pull origin master. This is commit with fix: Fix unsubscribe push notifications

GuleriaAshish commented 3 years ago

@Kachanov-dev i have checked your commit. you was sending token than subscription id in your sample. But my problem is i am not using your sample project right now as i am implementing it in my app. And you can check the logs that i am correctly sending the subscriptionId there.

Kachanov-dev commented 3 years ago

@GuleriaAshish , you need to send a DEVICE_SUBSCRIPTION_ID.

// Subscribe to push notification (we save the subscription.id)
ConnectyCube.pushnotifications.subscriptions.create(params)
  .then(result => {
    AsyncStorage.setItem(PushNotificationService.DEVICE_SUBSCRIPTION_ID, `${result[0].subscription.id}`)
  })
// When we unsubscribe from push notifications
async unsubscribePushNotifications() {
  const subscriptionIdToDelete = await AsyncStorage.getItem(AuthService.DEVICE_SUBSCRIPTION_ID)
  ConnectyCube.pushnotifications.subscriptions.delete(subscriptionIdToDelete);
}

Please read the documentation: Subscribe to push notifications: Unsubscribe from push notifications