• Home
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • General
  • News & Announcements
  • Ideas
  • RingCentral Office
    • Getting Started
    • Authentication
    • App Graduation
    • API Betas & Developer Previews
    • REST API
      • Call Management API
      • Glip API
      • Meetings API
      • Messaging API (SMS, Fax, Voicemail)
      • Provisioning API
      • Voice and Telephony API
    • Environment (Sandbox, Gateway)
    • SDKs
    • Admin & Credentials
  • RingCentral Engage
    • Getting Started
    • REST API
      • Interactions API
      • Provisioning API
      • Routing API
  • Jobs/Requests for Help
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Users
  • Badges
Skip to main content
  • Create
    • Ask a question
    • Create an article
    • Post an idea
    • General
    • News & Announcements
    • Ideas
    • RingCentral Office
      • Getting Started
      • Authentication
      • App Graduation
      • API Betas & Developer Previews
      • REST API
        • Call Management API
        • Glip API
        • Meetings API
        • Messaging API (SMS, Fax, Voicemail)
        • Provisioning API
        • Voice and Telephony API
      • Environment (Sandbox, Gateway)
      • SDKs
      • Admin & Credentials
    • RingCentral Engage
      • Getting Started
      • REST API
        • Interactions API
        • Provisioning API
        • Routing API
    • Jobs/Requests for Help
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Sign in
  • Home
  • RingCentral Office
  • REST API

question

Muhammad Shoaib avatar image
Muhammad Shoaib asked · Nov 20 at 03:28 PM

Subscription renewal Explain

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?

smssubscriptionspresencenode
Comment
0
1 |1000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

4 Answers

· Write an Answer
  • Sort by Created Created
  • Sort by Oldest Oldest
  • Sort by Votes Votes
Phong Vu avatar image
Phong Vu answered · Nov 20 at 11:16 PM ACCEPTED ANSWER

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.

0 · Share
1 |1000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered · Nov 20 at 09:44 PM

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?

0 · Share
1 |1000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Muhammad Shoaib avatar image
Muhammad Shoaib answered · Nov 20 at 10:14 PM

@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?

0 · Share
1 |1000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Muhammad Shoaib avatar image
Muhammad Shoaib answered · Nov 21 at 01:48 PM

@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.

· 1 comment · Share
1 |1000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ · Nov 21 at 05:01 PM

Read this doc at the section "When should I use a Webhook vs PubNub".

Also, Webhook subscription expiration time is much longer (7 days) so you need to renew just once in a while.

1 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

question details

3 People are following this question.

Phong1426275020 follows this question Muhammad2734456020 follows this question Dave2526243036 follows this question
Answers Subscribe to Answers Answers and Comments Subscribe to Comments and Answers

Related Questions

SMS API messages not recognized as legit SMS? 1 Answer

[sandbox] unable to capture payload on server side. 2 Answers

3rd party SMS Integration 2 Answers

Webhook subscription error C# 2 Answers

Any size limit for sms text size? 2 Answers

  • Developer Home
  • ·
  • Community Guidelines
  • ·
  • Legal
  • ·
  • Privacy Notice