CleverPush Developer Docs

CleverPush Developer Docs

  • SDK Docs
  • API Overview
  • API Reference

›Cordova SDK

JavaScript SDK

  • Setup
  • Methods

iOS SDK

  • Setup
  • Methods
  • Inbox View
  • Chat
  • Stories
  • Deep Links
  • Live Activities
  • Troubleshooting
  • Changelog

Android SDK

  • Setup
  • Methods
  • Notification Service Extension
  • Inbox View
  • Chat
  • Stories
  • Deep Links
  • Troubleshooting
  • Upgrading
  • Geo Fence Location Permission
  • Changelog

Capacitor SDK

  • Setup
  • Methods
  • Changelog

Cordova SDK

  • Setup
  • Methods
  • Changelog

React Native SDK

  • Setup
  • Methods
  • Changelog

Xamarin SDK

  • Setup
  • Methods
  • Changelog

Flutter SDK

  • Setup
  • Methods
  • Chat
  • Troubleshooting
  • Changelog

Methods

Initialization

Add the initialization code to your index.js file

document.addEventListener('deviceready', () => {
  const notificationReceivedListener = (data) => {
    console.log('CleverPush notification received:', JSON.stringify(data));
  };

  const notificationOpenedListener = (data) => {
    console.log('CleverPush notification opened:', JSON.stringify(data));
  };

  const subscribedListener = (subscriptionId) => {
    console.log('CleverPush subscriptionId:', subscriptionId);
  };

  // set this to `false` to prevent the SDK from automatically subscribing the user on the first launch of the SDK
  const autoRegister = true;

  window.plugins.CleverPush.init(
    "INSERT_YOUR_CHANNEL_ID",
    notificationReceivedListener,
    notificationOpenedListener,
    subscribedListener,
    autoRegister
  );
}, false);

Be sure to replace INSERT_YOUR_CHANNEL_ID with your CleverPush channel ID (can be found in the channel settings).

Basic usage

Subscribe:

window.plugins.CleverPush.subscribe();

Unsubscribe:

window.plugins.CleverPush.unsubscribe();

Check if subscribed:

window.plugins.CleverPush.isSubscribed((err, isSubscribed) => {
  
});

Get Subscription ID (after subscribe)

window.plugins.CleverPush.getSubscriptionId((err, subscriptionId) => {
  
});

Notification Received Callback Listener

Instead of a regular NotificationReceivedListener you could also use a NotificationReceivedCallbackListener. This way you can dynamically control if you want to show a notification when the app is running in foreground:

window.plugins.CleverPush.setNotificationReceivedCallbackListener(function(data) {
  console.log('CleverPush notification received:', JSON.stringify(data));
  var showInForeground = true;
  window.plugins.CleverPush.setNotificationReceivedCallbackResult(data.notification._id, showInForeground);
});

(Only supported on Android)

App Banners

This listener will be called when a button in an app banner is clicked.

window.plugins.CleverPush.setAppBannerOpenedListener((action) => {
  console.log('App Banner opened:', action);
});
← SetupChangelog →
  • Initialization
  • Basic usage
  • Notification Received Callback Listener
  • App Banners
SDKs
JavaScriptiOSAndroidCordovaCapacitorReact NativeXamarinFlutter
Community
TwitterFacebookGitHub
More
API ReferenceAPI OverviewBlogImprintPrivacy PolicyTerms of serviceGDPR
Copyright © 2025 CleverPush