I'm bit confused about subscription renewal, I've successfully followed the tutorial for presence events and I now get notified, but after I went through this tutorial https://ringcentral-tutorials.github.io/subscription-basics-nodejs-demo/ I'm confused about subscription renewals do they get handled internally or do we need to use an API after every x interval to renew the subscription to make sure we keep getting the notifications?
Subscription renewal Explain
First of all, the SDK renews the subscription automatically as long as the access token is still valid. You should implement the callback functions to decide what to do:
// Register Platform Event Listeners platform.on(platform.events.refreshSuccess, handleRefreshSuccess); platform.on(platform.events.refreshError, handleRefreshError); // Register Subscription Event Listeners subscription.on(subscription.events.renewSuccess, handleSubscriptionRenewSuccess); subscription.on(subscription.events.renewError, handleSubscriptionRenewError);
What is the tutorial for presence do you refer to?
@Phong Vu sorry for omitting the info, this is the presence tutorial I was referring to https://ringcentral-tutorials.github.io/callrecording-notification-node/?distinctId=16e69c9b43c9e-0f45863320bf05-1d3d6b55-13c680-16e69c9b43dc9b, also I couldn't find anything related to handling the disconnection from ringcentral server, more precisely how can we handle the disconnect if we are disconnected from this
var platform = rcsdk.platform(); platform.login({ username:un, password:pwd }).then()
what I am looking for is to reconnect after we get disconnected and then do we need to re-do the subscription process?
That tutorial does not discuss about renew a subscription. The reason I added 2 additional functions to check existing subscription and remove the subscription was explained in the tutorial (don't want to have many pending subscriptions while rerun app too often to test).
Basically, the SDK support PubNub notification and it expires after 15 minutes. That's why the SDK was implemented to refresh the notification more frequently.
You said "disconnection from RingCentral server", do you mean the app/user logout or terminate the app? Anyway, you can call the platform.logout() to log out deliberately.
If you want to check if your app is still logged in (meaning the access token is still valid) you can call platform.loggedIn() which returns true or false accordingly. If it returns false, then call platform.login() to login again. If it is true, you are good to call any APIs.
If you app suppose to run for weeks or months continuously, I recommend to use Webhooks notifications instead of PubNub notification. Check this quick start to learn more about RingCentral Webhooks.
@Phong Vu by disconnection I meant if the app logouts for some reason (internet connectivity issue). but I guess we can just check using the loggedin() and call login() if true. Also can you kindly shed some light on as to why webhooks are preferred over pubnub for app that's meant to run for weeks or months continuously.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.