Shridhar Joshi
Shridhar Joshi

Reputation: 21

Create subscription after token refreshed

I have set RC object to auto refresh the token, and subscribed to the detailedtelephony event to get incoming call notifcation. I have also subscribed to autorefresh event of RC object to get the refreshed token and assigned it to global RC object.This works fine. I would like to know if the token gets refreshed after every hour or so, do we need to subscribe to the detailedtelephony event again i.e. everytime token get refreshed?

Upvotes: 1

Views: 212

Answers (1)

Paco Vu
Paco Vu

Reputation: 211

You don't need to subscribe again for RingCentral push notification events (including the detailedtelephony) after refreshing your RC object access token. It is for you to access the platform.

However, the push notification subscription will expire regardless of the access/refresh token.

  • PubNub subscriptions will expire in 15 mins. RingCentral SDKs will automatically renew this for you so as long as your app is running, you don't need to do anythign special to renew.
  • WebHook subscriptions expire in 7 days by default. After the notification expired, you can just call to renew it (/restapi/v1.0/subscription/{subscriptionId}/renew). You can also set a long expiration time in seconds such as "expiresIn": 500000000 for just over 15 years so you don't have to worry about renewal.

This is how you should implement in your app:

  1. Subscribe for an event.
  2. Parse the response to keep the subscription Id and the expiresIn or the expirationTime.
  3. Set a timer based on the expiresIn (seconds) to call the renew endpoint. (you need the valid access token to call this endpoint though)
  4. Or, set a timer based on the expirationTime (remember to convert the time zone to your local time) then call the renew endpoint when your timer fires off. (you need the valid access token to call this endpoint though)

You can see an example of a long-lived token in the bot documentation here:

https://ringcentral-api-docs.readthedocs.io/en/latest/glip_bots/

Upvotes: 1

Related Questions