Closed GuleriaAshish closed 3 years ago
@ccvlad please suggest me what i am doing wrong .
Hi, @GuleriaAshish
I think you have not logged in to ConnectyCube. https://developers.connectycube.com/js/authentication-and-users?id=session-token-rights
Hi, @GuleriaAshish
I think you have not logged in to ConnectyCube. https://developers.connectycube.com/js/authentication-and-users?id=session-token-rights
Thanks for the quick reply @ccvlad , really appreciate your efforts. I have logged in to connectycube successfully. And as i can see create subscription api require deviceToken which i have provided.
@ccvlad any solution for this ? as i am still not able to figure it out.
Please provide a full log, from ConnectyCube.createSession to ConnectyCube.pushnotifications.subscriptions.create
I am implementing notifications code in my app.js class. And in onRegister() method of notifications i am calling ConnectyCube.pushnotifications.subscriptions.create() this method with the token that i get from onRegister() method just like explained in your documentation.
I think there is no relation with connectycube session. That may take part when i am willing to send the notification but on subscription i don't think it is needed .
And the most important part is we can not createSession in app.js it must be created when we login .
Could you show your logs? You can not request to API w/o session
[Response][1] {"session": {"application_id": 3448, "created_at": "2020-10-21T07:51:09Z", "id": 18537738, "nonce": 5077, "token": "65b09550bf95295b5b3074339054e1c976000d78", "ts": 1603266667, "updated_at": "2020-10-21T07:51:09Z", "user": {"avatar": "", "blob_id": null, "created_at": "2020-10-13T09:05:01Z", "custom_data": "", "email": null, "external_user_id": null, "facebook_id": null, "full_name": "Ashish Guleria", "id": 2190208, "last_request_at": "2020-10-21T07:51:09Z", "login": "Ashish", "phone": "9882744034", "twitter_id": null, "updated_at": "2020-10-21T07:51:09Z", "user_tags": null, "website": null}, "user_id": 2190208}}
[Wed Oct 21 2020 13:21:09.358] LOG [Chat] Connect with parameters {"password": "Mind#123", "userId": 2190208}
[Wed Oct 21 2020 13:21:09.358] LOG [Chat] status connecting wss://chat.connectycube.com:5291
[Wed Oct 21 2020 13:21:11.144] LOG [Chat] status connect
[Wed Oct 21 2020 13:21:11.145] LOG [Chat] CONNECTING
[Wed Oct 21 2020 13:21:11.146] LOG [Chat] status opening
[Wed Oct 21 2020 13:21:11.146] LOG [Chat] SENT:
@GuleriaAshish
The log is not full.
Anyway, your steps should be:
ConnectyCube.init(appCreds, appConfig);
ConnectyCube.createSession(userParams).then(session => {
ConnectyCube.pushnotifications.subscriptions.create(params);
});
@ccvlad ,i am closing this issue as it's working now. Thanks for the help.
I am trying to integrate push notification with connetycube. But when i tried to hit ConnectyCube.pushnotifications.subscriptions.create(params) method with params that provided in documentation then it results a error code 401, {"code": 401, "info": {"errors": ["Token is required"]}}
code sample: Method decleration: const subcribeToPushNotification = (deviceToken) => { const DeviceInfo = require('react-native-device-info').default const params = { notification_channel: Platform.OS === 'ios' ? 'apns' : 'gcm', device: { platform: Platform.OS, udid: DeviceInfo.getUniqueId() }, push_token: { environment: 'development', client_identification_sequence: deviceToken, bundle_identifier: "com.afyanet" } } console.warn("param", params) // JS SDK v2+ ConnectyCube.pushnotifications.subscriptions.create(params) .then(result => { console.warn("suc", result) }) .catch(error => { console.warn("err", error) });
}
Calling methods subcribeToPushNotification: // (optional) Called when Token is generated (iOS and Android) onRegister: function (token) {