CleverPush Developer Docs

CleverPush Developer Docs

  • SDK Docs
  • API Overview
  • API Reference

›iOS 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
  • Stories
  • Troubleshooting
  • Changelog

Expo SDK

  • Setup
  • Methods
  • Changelog

Methods

Basic usage

Swift
Objective-C
// init with autoRegister:false to manually subscribe later
CleverPush.initWithLaunchOptions(launchOptions,
channelId: "YOUR_CHANNEL_ID_HERE",
handleNotificationReceived:{ result in
if let value = result?.notification.value(forKey: "url") {
print("Received Notification with URL: \(value)")
}
},
handleNotificationOpened:{ result in
if let value = result?.notification.value(forKey: "url") {
print("Opened Notification with URL: \(value)")
}
},
handleSubscribed:{ subscriptionId in
print("Subscribed to CleverPush with ID: \(subscriptionId ?? "")")
},
autoRegister: false
)

//get the locally stored notification.
let localNotifications = CleverPush.getNotifications()

// get remote notification and local notification based on the boolean argument.
// - if you pass boolean argument true you will get the list of remote notification else you will get the locally stored notification.
CleverPush.getNotifications(true, callback: { remoteNotification in
print(remoteNotification as Any)
})

// subscribe
CleverPush.subscribe()

// unsubscribe later
CleverPush.unsubscribe()

// get subscription status
let isSubscribed = CleverPush.isSubscribed()
// init with autoRegister:false to manually subscribe later
[CleverPush initWithLaunchOptions:launchOptions
channelId:@"YOUR_CHANNEL_ID_HERE"
handleNotificationReceived:^(CPNotificationReceivedResult *result) {
NSLog(@"Received Notification with URL: %@", [result.notification valueForKey:@"url"]);
handleNotificationOpened:^(CPNotificationOpenedResult *result) {
NSLog(@"Opened Notification with URL: %@", [result.notification valueForKey:@"url"]);
} handleSubscribed:^(NSString *subscriptionId) {
NSLog(@"Subscribed to CleverPush with ID: %@", subscriptionId);
}
autoRegister:NO
];

//get the locally stored notification.
NSArray *localNotifications = [CleverPush getNotifications];

// get remote notification and local notification based on the boolean argument.
// - if you pass boolean argument YES you will get the list of remote notification else you will get the locally stored notification.
[CleverPush getNotifications:YES callback:^(NSArray *remoteNotification) {
NSLog(@"%@", remoteNotification);
}];

// subscribe
[CleverPush subscribe]

// unsubscribe later
[CleverPush unsubscribe]

// get subscription status
BOOL isSubscribed = [CleverPush isSubscribed]

Mark/Unmark Subscription As Test

You can mark or unmark a subscription as a test subscription.

Mark Subscription As Test

(Available from version 1.34.43)

Marks the current subscription as a test subscription.

Call this method after CleverPush has been initialized and a subscription ID is available.

Swift
Objective-C
// Mark subscription as test
CleverPush.markSubscriptionAsTest()

// Mark subscription as test with success/failure callbacks
CleverPush.markSubscriptionAsTest(onSuccess: { results in
// success
}, onFailure: { error in
// handle error
})
// Mark subscription as test
[CleverPush markSubscriptionAsTest];

// Mark subscription as test with success/failure callbacks
[CleverPush markSubscriptionAsTestOnSuccess:^(NSDictionary *results) {
// success
} onFailure:^(NSError *error) {
// handle error
}];

Unmark Subscription As Test

(Available from version 1.34.47)

To unmark a subscription as test. Removes the test status from the current subscription.

Call this method after CleverPush has been initialized and a subscription ID is available.

Swift
Objective-C
// Unmark subscription as test
CleverPush.unmarkSubscriptionAsTest()

// Unmark subscription as test with success/failure callbacks
CleverPush.unmarkSubscriptionAsTest(onSuccess: { results in
// success
}, onFailure: { error in
// handle error
})
// Unmark subscription as test
[CleverPush unmarkSubscriptionAsTest];

// Unmark subscription as test with success/failure callbacks
[CleverPush unmarkSubscriptionAsTest:^(NSDictionary *results) {
// success
} onFailure:^(NSError *error) {
// handle error
}];

Tags

Swift
Objective-C
// get available tags
let channelTags = CleverPush.getAvailableTags()

// add/remove tag with action callback
CleverPush.addSubscriptionTag("TAG_ID", callback: { tagId in
print(tagId as Any)
})

CleverPush.removeSubscriptionTag("TAG_ID", callback: { tagId in
print(tagId as Any)
})

// add/remove multiple tags with action callback
let tags = ["TAG_ID1", "TAG_ID2"];

CleverPush.addSubscriptionTags(tags, callback: { addedTags in
print(addedTags as Any)
})

CleverPush.removeSubscriptionTags(tags, callback: { remainingTags in
print(remainingTags as Any)
})

// add/remove tag without action callback
CleverPush.addSubscriptionTag("TAG_ID")
CleverPush.removeSubscriptionTag("TAG_ID")

// add/remove multiple tags without action callback
CleverPush.addSubscriptionTags(tags)
CleverPush.removeSubscriptionTags(tags)

let hasTag = CleverPush.hasSubscriptionTag("TAG_ID")

let subscriptionTags = CleverPush.getSubscriptionTags()
let subscriptionTopics = CleverPush.getSubscriptionTopics()
CleverPush.setSubscriptionTopics(["ID_1", "ID_2"])
// get available tags
NSArray* channelTags = [CleverPush getAvailableTags];

// add/remove tag with action callback
[CleverPush addSubscriptionTag:@"TAG_ID" callback:^(NSString *tagId) {
NSLog(@"%@",tagId);
}];

[CleverPush removeSubscriptionTag:@"TAG_ID" callback:^(NSString *tagId) {
NSLog(@"%@",tagId);
}];

// add/remove multiple tags with action callback
NSArray *tags = @[@"TAG_ID1", @"TAG_ID2"];

[CleverPush addSubscriptionTags:tags callback:^(NSArray *addedTags) {
NSLog(@"%@",addedTags);
}];

[CleverPush removeSubscriptionTags:tags callback:^(NSArray *remainingTags) {
NSLog(@"%@",remainingTags);
}];

// add/remove tag without action callback
[CleverPush addSubscriptionTag:@"TAG_ID"];
[CleverPush removeSubscriptionTag:@"TAG_ID"];

// add/remove multiple tags without action callback
[CleverPush addSubscriptionTags:tags];
[CleverPush removeSubscriptionTags:tags];

BOOL hasTag = [CleverPush hasSubscriptionTag:@"TAG_ID"];

NSArray* subscriptionTags = [CleverPush getSubscriptionTags];
NSArray* subscriptionTopics = [CleverPush getSubscriptionTopics];
[CleverPush setSubscriptionTopics:@{@"ID_1", @"ID_2"}];

Automatic Tag Assignment

The SDK can also automatically assign tags by using the trackPageView method. In simple cases you can just give the method a URL. In the CleverPush backoffice you can then set trigger the tags by matching URL Pathname RegExes. You can optionally also set combinations of min. visits, seconds or sessions for this tag.

Let's say you have created a tag with the URL pathname regex "/sports". This would trigger the tag for a subscriber:

Swift
Objective-C
CleverPush.trackPageView("https://example.com/sports/article-123123")
[CleverPush trackPageView:@"https://example.com/sports/article-123123"];

We can also have more advanced use cases here by using Javascript functions for matching. For example you created a tag with the following function in the CleverPush backend: params.category === "sports". This would then trigger the tag for a subscriber:

Swift
Objective-C
CleverPush.trackPageView("https://example.com/anything", params: ["category" : "sports"])
[CleverPush trackPageView:@"https://example.com/anything" params:[NSDictionary dictionaryWithObjectsAndKeys: @"sports", @"category", nil]];

Once the trackPageView method has been implemented you can set up all the tags dynamically in the CleverPush backend without touching your code.

Topics

Swift
Objective-C
//set the tint color for the topic attributes (save button and switches)
CleverPush.setNormalTintColor(UIColor .systemPurple);

//set branding color while you're going to enable highlighting newly added topic
CleverPush.setBrandingColor(UIColor .systemRed);

// get all the subscription topics
let subscriptionTopics = CleverPush.getSubscriptionTopics()

// set multiple subscription topics
CleverPush.setSubscriptionTopics(["ID_1", "ID_2"])

// get all the available topics
CleverPush.getAvailableTopics { channelTopics_ in
print(channelTopics_ as Any)
}

// add a single topic
CleverPush.addSubscriptionTopic("ID_1")

// remove a single topic
CleverPush.removeSubscriptionTopic("ID_1")

let hasTopic = CleverPush.hasSubscriptionTopic("TOPIC_ID");

// let the user choose his topics
CleverPush.showTopicsDialog()
//set the tint color for the topic attributes (save button and switches)
[CleverPush setNormalTintColor:[UIColor systemPurpleColor]];

//set branding color while you're going to enable highlighting newly added topic
[CleverPush setBrandingColor:[UIColor systemRedColor]];

// get all the subscription topics
NSArray* subscriptionTopics = [CleverPush getSubscriptionTopics];

// set multiple subscription topics
[CleverPush setSubscriptionTopics:@{@"ID_1", @"ID_2"}];

// get all the available topics
[CleverPush getAvailableTopics:^(NSArray* channelTopics_) {
NSLog(@"CleverPush: Available topics %@", channelTopics_);
}];

// add a single topic
[CleverPush addSubscriptionTopic:@"ID_1"];

// remove a single topic
[CleverPush removeSubscriptionTopic:@"ID_1"];

BOOL hasTopic = [CleverPush hasSubscriptionTopic:@"TOPIC_ID"];

// let the user choose his topics
[CleverPush showTopicsDialog];

[CleverPush setTopicsChangedListener:^(NSArray* topicsIds) {
NSLog(@"CleverPush: Changed topicsIds %@", topicsIds);
});

Here is how the topics dialog looks like:

Topics Dialog iOS

Attributes

Swift
Objective-C

// Retrieve all available attributes
CleverPush.getAvailableAttributes { availableAttributes in
print(availableAttributes as Any)
}

// Get all subscription attributes
let subscriptionAttributes = CleverPush.getSubscriptionAttributes()

// Get a single subscription attribute value
let attributeValue = CleverPush.getSubscriptionAttribute("ATTRIBUTE_ID")

// Set a string value
CleverPush.setSubscriptionAttribute("ATTRIBUTE_ID", value: "ATTRIBUTE_VALUE")

// Set an array of strings
let valArray = ["ATTRIBUTE_VALUE_ONE", "ATTRIBUTE_VALUE_TWO", "ATTRIBUTE_VALUE_THREE", "ATTRIBUTE_VALUE_FOUR"]
CleverPush.setSubscriptionAttribute("ATTRIBUTE_ID", arrayValue: valArray)

// Please provide dates in the following format: YYYY-MM-DD
CleverPush.setSubscriptionAttribute("birthdate", value: "2020-06-21")

// Set multiple key-value pairs at once
let attributes: [String: String] = ["user_id": "1", "zip": "20097"]
CleverPush.setSubscriptionAttributes(attributes)

// Remove a single attribute
CleverPush.removeSubscriptionAttribute("ATTRIBUTE_ID")

// Remove a single attribute with success/failure callback
CleverPush.removeSubscriptionAttribute("ATTRIBUTE_ID", callback: { attributeId in
// success, attributeId is the removed attribute key
}, onFailure: { error in
// handle error
})

//// Remove multiple attributes
CleverPush.removeSubscriptionAttributes(["ATTRIBUTE_ID1", "ATTRIBUTE_ID2", "ATTRIBUTE_ID3"])
// Retrieve all available attributes
[CleverPush getAvailableAttributes^(NSDictionary* availableAttributes) {
NSLog(@"CleverPush: Available attributes %@", availableAttributes);
}];

// Get all subscription attributes
NSDictionary* subscriptionAttributes = [CleverPush getSubscriptionAttributes];

// Get a single subscription attribute value
NSString* attributeValue = [CleverPush getSubscriptionAttribute:@"ATTRIBUTE_ID"];

// Set a string value
[CleverPush setSubscriptionAttribute:@"ATTRIBUTE_ID" value:@"ATTRIBUTE_VALUE"];

// Set an array of strings
NSArray *valArray = @[@"ATTRIBUTE_VALUE_ONE", @"ATTRIBUTE_VALUE_TWO", @"ATTRIBUTE_VALUE_THREE", @"ATTRIBUTE_VALUE_FOUR"];
[CleverPush setSubscriptionAttribute:@"ATTRIBUTE_ID" arrayValue:valArray];

// Please provide dates in the following format: YYYY-MM-DD
[CleverPush setSubscriptionAttribute:@"birthdate" value:@"2020-06-21"];

// Set multiple key-value pairs at once
NSDictionary<NSString *, NSString *> *attributes = @{@"user_id": @"1", @"zip": @"20097"};
[CleverPush setSubscriptionAttributes:attributes];

// Remove a single attribute
[CleverPush removeSubscriptionAttribute:@"ATTRIBUTE_ID"];

// Remove a single attribute with success/failure callback
[CleverPush removeSubscriptionAttribute:@"ATTRIBUTE_ID" callback:^(NSString *attributeId) {
// success
} onFailure:^(NSError *error) {
// handle error
}];

// Remove multiple attributes
[CleverPush removeSubscriptionAttributes:@[@"ATTRIBUTE_ID1", @"ATTRIBUTE_ID2", @"ATTRIBUTE_ID3"]];

// You can also push/pull values to special array attributes (e.g. "categories")

Swift
Objective-C
CleverPush.pushSubscriptionAttributeValue("categories", value: "category_1");
CleverPush.pullSubscriptionAttributeValue("categories", value: "category_1");
[CleverPush pushSubscriptionAttributeValue:@"categories" value:@"category_1"];

[CleverPush pullSubscriptionAttributeValue:@"categories" value:@"category_1"];

Keep Targeting Data On Unsubscribe

By default, the SDK automatically removes the following data from local storage when a user unsubscribes: Subscription ID, Topics, Tags, Attributes

The default value of keepTargetingDataOnUnsubscribe is false.

Set keepTargetingDataOnUnsubscribe to true to retain user targeting data locally even after the user unsubscribes.

This ensures that Topics, Tags, and Attributes are preserved locally, even when the user is no longer subscribed.

The subscriptionId is always removed and is not controlled by this flag.

On every unsubscribe() call, the SDK removes: Subscription ID, Related sync/created fields

When keepTargetingDataOnUnsubscribe is enabled (true), the SDK keeps only: Topics, Topic version, Tags, Attributes

Swift
Objective-C
CleverPush.setKeepTargetingDataOnUnsubscribe(true)
[CleverPush setKeepTargetingDataOnUnsubscribe:YES];

Get Device Token

You can retrieve the current device token (used for push notifications) with the following method:

Swift
Objective-C
CleverPush.getDeviceToken { deviceToken in
print("Device Token: \(deviceToken ?? "")")
}
[CleverPush getDeviceToken:^(NSString *deviceToken) {
NSLog(@"Device Token: %@", deviceToken);
}];

Country & Language

You can optionally override the country & language which is automatically detected from the system and can be used for targeting / translations.

Swift
Objective-C
CleverPush.setSubscriptionLanguage("en");
CleverPush.setSubscriptionCountry("US");
[CleverPush setSubscriptionLanguage:@"en"];
[CleverPush setSubscriptionCountry: @"US"]

Received Notifications

(App Group from setup step 10 is required):

Swift
Objective-C
let notifications = CleverPush.getNotifications() as? [CPNotification]
print(notifications as Any)
print(notifications?[0].id as String)

NSArray* notifications = [CleverPush getNotifications];

Tracking Notification Clicks

You can use the trackInboxClicked() method from the CPNotification object to manually track clicks on notifications retrieved either from local storage or remotely.

This is especially useful if you're displaying a custom inbox UI.

Swift
Objective-C
if let notifications = CleverPush.getNotifications() as? [CPNotification] {
for notification in notifications {
// Track a notification click
notification.trackInboxClicked()
}
}

CleverPush.getNotifications(true) { remoteNotifications in
if let notifications = remoteNotifications as? [CPNotification] {
for notification in notifications {
// Track a notification click
notification.trackInboxClicked()
}
}
}
NSArray *notifications = [CleverPush getNotifications];
for (CPNotification *notification in notifications) {
// Track a notification click
[notification trackInboxClicked];
}

[CleverPush getNotifications:YES callback:^(NSArray *remoteNotifications) {
for (CPNotification *notification in remoteNotifications) {
// Track a notification click
[notification trackInboxClicked];
}
}];

Notification Read Status

(Available from version 1.34.24)

You can mark a notification as read or unread, and check whether a notification has been read.

Swift
Objective-C
// Mark notification as read
CleverPush.setNotificationRead("NOTIFICATION_ID", read: true)

// Mark notification as unread
CleverPush.setNotificationRead("NOTIFICATION_ID", read: false)

// Check if a notification has been read
let isRead = CleverPush.getNotificationRead("NOTIFICATION_ID")
// Mark notification as read
[CleverPush setNotificationRead:@"NOTIFICATION_ID" read:YES];

// Mark notification as unread
[CleverPush setNotificationRead:@"NOTIFICATION_ID" read:NO];

// Check if a notification has been read
BOOL isRead = [CleverPush getNotificationRead:@"NOTIFICATION_ID"];

Remove Notification

You can remove notification stored locally using Notification ID

Swift
Objective-C
CleverPush.removeNotification("notification_Id")
[CleverPush removeNotification:@"notification_Id"];

Remove all notifications from local storage

(Available from version 1.34.37)

You can remove all notifications stored locally using the following method (this does not clear any notifications from notification center):

Swift
Objective-C
CleverPush.removeAllNotifications()
[CleverPush removeAllNotifications];

App Banners

(Available from version 1.3.0)

Swift
Objective-C
CleverPush.setAppBannerOpenedCallback { (_: CPAppBannerAction?) in
print("App Banner Opened")
}

// You can also show one banner by its ID (we recommend app banner events for production usage)
CleverPush.showAppBanner("BANNER_ID")

// You can show a banner by its ID and receive a callback when it is dismissed (available from version 1.34.7).
CleverPush.showAppBanner("APP_BANNER_ID") {
print("App banner was dismissed");
};

[CleverPush setAppBannerOpenedCallback:^(CPAppBannerAction *action) {
NSLog(@"App Banner Opened");
}];

// You can also show one banner by its ID (we recommend app banner events for production usage)
[CleverPush showAppBanner:@"BANNER_ID"];

// You can show a banner by its ID and receive a callback when it is dismissed (available from version 1.34.7).
[CleverPush showAppBanner:@"APP_BANNER_ID" appBannerClosedCallback:^{
NSLog(@"App banner was dismissed");
}];

Get banners by group ID

Swift
Objective-C
CleverPush.getAppBanners(byGroup: groupId) { banners in
// do something with the banners
}
[CleverPush getAppBannersByGroup:groupId callback:^(NSArray<CPAppBanner *> *banners) {
// do something with the banners
}];

Custom Fonts for App Banners

You can apply custom fonts to app banner text and buttons to match your app branding.

Supported Font Formats

The following font formats are supported:

  • .ttf - TrueType
  • .otf - OpenType

Step 1: Add the font files to your iOS app

  1. Drag your font files (for example OpenSans-Regular.ttf) into your Xcode project.
  2. Make sure the files are added to your app target.
  3. Verify they appear in Build Phases -> Copy Bundle Resources.

Example (font files in project):

iOS Fonts Folder Example

Example (Copy Bundle Resources):

iOS Copy Bundle Resources Example

Step 2: Register fonts in Info.plist

Add the Fonts provided by application (UIAppFonts) key and list all font files (with extension):

<key>UIAppFonts</key>
<array>
  <string>OpenSans-Regular.ttf</string>
  <string>OpenSans-Bold.ttf</string>
  <string>OpenSans-Italic.ttf</string>
  <string>OpenSans-Light.ttf</string>
  <string>OpenSans-LightItalic.ttf</string>
  <string>OpenSans-Semibold.ttf</string>
  <string>OpenSans-ExtraBold.ttf</string>
</array>

Example (UIAppFonts in Info.plist):

iOS UIAppFonts Info.plist Example

Step 3: Use the iOS font name in your App Banner

When configuring the banner font in the CleverPush dashboard:

  • Use the iOS internal font name (PostScript name), not necessarily the file name.
  • Example: file OpenSans-Regular.ttf can expose a font name like OpenSans-Regular.
  • Set the Font Family field to OpenSans-Regular.

Example (CleverPush dashboard font field):

iOS Dashboard Font Family Example

You can verify a font name in code:

Swift
Objective-C
if let font = UIFont(name: "OpenSans-Regular", size: 16) {
print("Loaded font: \(font.fontName)")
}
UIFont *font = [UIFont fontWithName:@"OpenSans-Regular" size:16];
if (font) {
NSLog(@"Loaded font: %@", font.fontName);
}

Use this resolved font name in the App Banner font fields.

Step 4: Build and test

  1. Rebuild and run your iOS app.
  2. Trigger the app banner.
  3. Confirm custom fonts are applied to the banner text and buttons.

Fallback Behavior

If the custom font is missing, named incorrectly, or cannot be loaded, the SDK falls back to the system font so the banner remains readable.

Disabling banners

You can also disable app banners temporarily, e.g. during a splash screen. Banners are enabled by default. If a banner would show during this time, it is added to an internal queue and shown when calling enableAppBanners.

Swift
Objective-C
CleverPush.disableAppBanners();
CleverPush.enableAppBanners();
[CleverPush disableAppBanners];
[CleverPush enableAppBanners];

Non-blocking banners

(Available from version 1.34.45)

By default, app banners block user interaction with the app while they are visible. You can allow users to interact with the app while an in-app banner is displayed by enabling the non-blocking mode.

Call this before initializing the SDK

Swift
Objective-C
CleverPush.setAppBannersNonBlocking(true);
[CleverPush setAppBannersNonBlocking:YES];

To restore the default blocking behaviour:

Swift
Objective-C
CleverPush.setAppBannersNonBlocking(false);
[CleverPush setAppBannersNonBlocking:NO];

Development mode

You can enable the development mode to disable caches for app banners, so you always see the most up to date version.

Swift
Objective-C
CleverPush.enableDevelopmentMode();
[CleverPush enableDevelopmentMode];

HTML Banners

CleverPush supports various JavaScript functions which can be called from HTML banners:

JavaScript
CleverPush.subscribe();
CleverPush.unsubscribe();
CleverPush.closeBanner();
CleverPush.trackEvent(eventId, propertiesObject);
CleverPush.trackClick(buttonId);
CleverPush.trackClick(buttonId, customDataObject);
CleverPush.openWebView(url);
CleverPush.setSubscriptionAttribute(attributeId, value);
CleverPush.addSubscriptionTag(tagId);
CleverPush.removeSubscriptionTag(tagId);
CleverPush.setSubscriptionTopics(topicIds);
CleverPush.addSubscriptionTopic(topicId);
CleverPush.removeSubscriptionTopic(topicId);
CleverPush.showTopicsDialog();
CleverPush.handleLinkBySystem('mailto:example@email.com'); // support multiple link types, including `mailto:`, `tel:`, `market/Play Store`, and standard `http/https` links.

Event Tracking

Events can be used to track conversions or trigger app banners.

Swift
Objective-C
CleverPush.trackEvent("EVENT NAME")

// track an event with custom properties
CleverPush.trackEvent("EVENT NAME", properties: ["property-1": "value"])

// track an event with a specified amount
CleverPush.trackEvent("EVENT NAME", amount: 37.50)

[CleverPush trackEvent:@"EVENT NAME"];

// track an event with custom properties
[CleverPush trackEvent:@"EVENT NAME" properties:@{
@"property-1": @"value"
}];

// track an event with a specified amount
[CleverPush trackEvent:@"EVENT NAME" amount:37.50];

Follow up Events

Deprecated: Use trackEvent instead to trigger Follow-ups via Events.

Events can be used to trigger follow-up campaigns.

Swift
Objective-C
CleverPush.triggerFollowUpEvent("EVENT NAME")

// add custom parameters
CleverPush.triggerFollowUpEvent("EVENT NAME", ["id": "123456"])

[CleverPush triggerFollowUpEvent:@"EVENT NAME"];

// add custom parameters
[CleverPush triggerFollowUpEvent:@"EVENT NAME" parameters:@{@"id": @"123456"}];

Tracking Consent

You can optionally require a tracking consent from the user (e.g. you get this consent from a CMP). If you tell our SDK to wait for the tracking consent, it will not call any tracking-related features until the consent is available. Calls will be queued and automatically executed until the consent is available.

Step 1: Call this before initializing the SDK:

Swift
Objective-C
CleverPush.setTrackingConsentRequired(true)
[CleverPush setTrackingConsentRequired:YES];

Step 2: Call this when the user gave his consent (needs to be called on every launch):

Swift
Objective-C
CleverPush.setTrackingConsent(true)
[CleverPush setTrackingConsent:YES];

Subscribe Consent

You can optionally require user consent for subscription (e.g., obtained through a CMP). If you tell our SDK to wait for the subscribe consent, it will not call subscribe features until the consent is available. Calls will be queued and automatically executed once consent is granted.

Step 1: Call this before initializing the SDK:

Swift
Objective-C
CleverPush.setSubscribeConsentRequired(true)
[CleverPush setSubscribeConsentRequired:YES];

Step 2: Call this when the user gave his consent (needs to be called on every launch):

Swift
Objective-C
CleverPush.setSubscribeConsent(true)
[CleverPush setSubscribeConsent:YES];

Authorization Token

You can set an authorization token that will be used in an API call.

Swift
Objective-C
CleverPush.setAuthorizerToken("YOUR_AUTH_TOKEN_HERE")
[CleverPush setAuthorizerToken:@"YOUR_AUTH_TOKEN_HERE"];

TCF2 CMP

You can set IabTcfMode. Perform subscribe or tracking according to IabTcfMode if vendor consent is 1.

Call this before initializing the SDK

Swift
Objective-C
// IabTcfModes are .subscribeWaitForConsent, .trackingWaitForConsent, .disabled
CleverPush.setIabTcfMode(.subscribeWaitForConsent)
// IabTcfModes are CPIabTcfModeSubscribeWaitForConsent, CPIabTcfModeTrackingWaitForConsent, CPIabTcfModeDisabled
[CleverPush setIabTcfMode:CPIabTcfModeSubscribeWaitForConsent];

Implementation of App Banner Delegate for Displaying Banners on Custom View Controllers

Implemented an App Banner Delegate feature allowing the display of banners on custom view controllers. This feature introduces a custom delegate or protocol for passing a view controller, enabling the presentation of banners on specific, user-defined views.

Swift
Objective-C
CleverPush.setShowAppBannerCallback { viewController in
print("App Banner will be displayed on ViewController: \(viewController)")
// Implement your logic to show the banner on the provided viewController
}
[CleverPush setShowAppBannerCallback:^(UIViewController *viewController) {
NSLog(@"App Banner will be displayed on ViewController: %@", viewController);
// Implement your logic to show the banner on the provided viewController
}];

Auto Request Notification Permission

You can diable the notification permission dialog while subscribe.

Default autoRequestNotificationPermission value is true so while subscribing it checks that if notification permission is not given then it will display the dialog. By seting autoRequestNotificationPermission value to false notification permission dialog will not display if permission is not given while subscribe.

Swift
Objective-C
// This method sets the boolean variable true or false.
CleverPush.setAutoRequestNotificationPermission(false)
// This method sets the boolean variable true or false.
[CleverPush setAutoRequestNotificationPermission:FALSE];

Auto Resubscribe

You can perform auto resubscribe whenever app open if the user has given notification permission and subscriptionId is null.

Default autoResubscribe value is false. By seting autoResubscribe value to true whenever app open it checks that the user has given notification permission and subscriptionId is null then perform subscribe.

Swift
Objective-C
// This method sets the boolean variable true or false.
CleverPush.setAutoResubscribe(true)
// This method sets the boolean variable true or false.
[CleverPush setAutoResubscribe:TRUE];

Set Local Track Event Retention Days

App Banners: Targeting by events from previous sessions

Added the Add Event feature in the Targeting section in the app banner. Where you can set the last x days event called and fulfil the specific condition then the banner will display.

E.g in last 5 days between from 5 to 10 event TEST. It will store the banner event data in a local database and check from the current date to till next five days. If the event called count for that particular banner is between 5 to 10 or not. If it's between those values then the banner will display otherwise not. After 5 days banner will not display.

To delete the local database's table entry need to set trackEventRetentionDays. The default days are 90 days. It will check each record's createdDateTime, if it's greater than trackEventRetentionDays then that data will be deleted from the table.

Call this before initializing the SDK

Swift
Objective-C
CleverPush.setLocalEventTrackingRetentionDays(20)
[CleverPush setLocalEventTrackingRetentionDays:20];

Set Application Notification Badge Count

You can set or get your application's badge count using the methods provided below.

  1. to get the application notification badge count
Swift
Objective-C
CleverPush.getBadgeCount{ badge in
print("Badge Count = %ld",badge)
}
[CleverPush getBadgeCount:^(NSInteger badge) {
NSLog(@"Badge Count = %ld",badge);
}];
  1. to set the application notification badge count
Swift
Objective-C
CleverPush.setBadgeCount(10)
[CleverPush setBadgeCount:10];

Handling Universal Links

When handling deep links automatically (setting in the CleverPush dashboard), you can instruct our SDK to open universal links (starting with http) inside the app instead of passing it as a deep link to the system. This is required to make universal links work.

  1. To specify which domains should be handled as universal links inside the app, you can use the setHandleUniversalLinksInAppForDomains method. This method allows you to pass an array of domains. If a URL's domain matches any of the specified domains, we will pass that matched URL as an NSUserActivity to the app itself.
Swift
Objective-C
let domains = ["domain1.com", "domain2.com","cleverpush.com"]
CleverPush.setHandleUniversalLinksInApp(forDomains: domains)
NSArray<NSString *> *domains = @[@"domain1.com", @"domain2.com",@"cleverpush.com"];
[CleverPush setHandleUniversalLinksInAppForDomains:domains];
  1. You can then simply handle the Deep Links within your AppDelegate/SceneDelegate code like shown in the examples below:
Swift
Objective-C
//For AppDelegate
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?)
-> Void) -> Bool {
print("URL = %@", userActivity.webpageURL)
return true;
}

//For SceneDelegate
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
print("URL = %@", userActivity.webpageURL)
}
//For AppDelegate
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
NSLog(@"URL = %@", userActivity.webpageURL);
return true;
}

//For SceneDelegate
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
NSLog(@"URL = %@", userActivity.webpageURL);
}

Customizing Notification Permissions And Settings

You can customize which notification permission options are requested when prompting the user for notification permissions.

These methods should be called before initializing the SDK to customize which notification permission options will be requested from the user. Each option can be enabled or disabled independently.

Swift
Objective-C
// Control whether notifications can show alerts (default: true)
CleverPush.setDisplayAlertEnabledForNotifications(true)

// Control whether notifications can play sounds (default: true)
CleverPush.setSoundEnabledForNotifications(true)

// Control whether notifications can update the app's badge count (default: true)
CleverPush.setBadgeCountEnabledForNotifications(true)
// Control whether notifications can show alerts (default: true)
[CleverPush setDisplayAlertEnabledForNotifications:YES];

// Control whether notifications can play sounds (default: true)
[CleverPush setSoundEnabledForNotifications:YES];

// Control whether notifications can update the app's badge count (default: true)
[CleverPush setBadgeCountEnabledForNotifications:YES];

Provisional Notification Authorization

(Available from version 1.34.52)

Enables provisional (non-interrupting) notification authorization on iOS 12+. Provisional notifications are delivered silently to the Notification Center without prompting the user for permission upfront. The user can then choose to keep or turn off notifications from the Notification Center itself.

This must be called before initializing the SDK.

Swift
Objective-C
CleverPush.setProvisionalNotificationAuthorizationEnabled(true)
[CleverPush setProvisionalNotificationAuthorizationEnabled:YES];

Piano Segments

(Available from version 1.34.46)

You can set and retrieve Piano segments for a subscription.

Set Piano Segments

The setPianoSegments method allows you to sync Piano segments to a subscription.

Swift
Objective-C
CleverPush.setPianoSegments(["PIANO_SEGMENT_ID_1", "PIANO_SEGMENT_ID_2"])
[CleverPush setPianoSegments:@[@"PIANO_SEGMENT_ID_1", @"PIANO_SEGMENT_ID_2"]];

Get Piano Segments

The getSubscriptionPianoSegments method returns the Piano segments associated with the current subscription.

Swift
Objective-C
let segments = CleverPush.getSubscriptionPianoSegments()
NSArray<NSString *> *segments = [CleverPush getSubscriptionPianoSegments];

Beacon Monitoring

(Available from version 1.34.50)

Beacon monitoring allows your app to detect nearby configured BLE beacons and automatically trigger events when a matching beacon is found.

After SDK initialization is complete, call initBeacons to enable beacon monitoring.

Configure beacons in the CleverPush dashboard under Channel → Beacons.

To detect nearby beacons, users must grant the required Bluetooth and precise location permissions depending on the Android version.

beacon integration

Initialize beacon monitoring using initBeacons().

Swift
Objective-C
CleverPushLocation.initBeacons()
[CleverPushLocation initBeacons];

On Beacon Detection

Receive a callback whenever a configured beacon UUID is detected and matched.

The corresponding event is already tracked automatically by the SDK.

Swift
Objective-C
CleverPushLocation.onBeaconDetected { beacon in
print("Beacon detected: \(beacon)")
}
[CleverPushLocation onBeaconDetected:^(NSDictionary *beacon) {
NSLog(@"Beacon detected: %@", beacon);
}];

Set Beacon Event Interval

Controls how frequently the same beacon event can be triggered during a single app session.

By default, a beacon event is triggered only once per app session. If the user remains within beacon range, the event will not trigger again.

You can configure an interval (in minutes) to allow the same beacon event to be triggered again after the specified time in same session.

Passing 0 disables throttling and triggers the event on every detection.

If not set then it will trigger only once per app session

Swift
Objective-C
CleverPushLocation.setBeaconEventInterval(5)
[CleverPushLocation setBeaconEventInterval:5];

Set Beacon Debug Scan All

Enables debug mode to log all detected BLE advertisements.

Default value is false, This option is intended only for debugging and diagnostics and should be disabled in production environments.

Call this before initBeacons().

Swift
Objective-C
CleverPushLocation.setBeaconDebugScanAll(true)
[CleverPushLocation setBeaconDebugScanAll:YES];

Clear Banner Delivery Dates

(Available from version 1.34.49)

You can reset the delivery date tracking for app banners. This is useful when you want to allow a banner to be displayed again before its scheduled next delivery time.

Clear a specific banner's delivery date

Swift
Objective-C
CleverPush.clearBannerDeliveryDate("BANNER_ID")
[CleverPush clearBannerDeliveryDate:@"BANNER_ID"];

Clear all banners' delivery dates

Swift
Objective-C
CleverPush.clearAllBannerDeliveryDates()
[CleverPush clearAllBannerDeliveryDates];

Set Group Notification Sound Mode

(Available from version 1.34.52)

By default, every incoming push notification plays a sound. When multiple notifications are grouped, this may result in repeated notification sounds for the same group.

Available modes:

  • AllNotifications (default) – Every notification plays a sound.
  • FirstInGroupOnly – Only the first notification in a group plays a sound. Notifications added to the same group while it remains visible in the notification center are delivered silently. Once the group has been cleared (dismissed or opened), the next notification in that group will play a sound again.

You can configure this behavior using setGroupNotificationSoundMode:

Swift
Objective-C
// Only the first notification in a group plays a sound.
// Subsequent notifications added to the same group are delivered silently.
CleverPush.setGroupNotificationSoundMode(.firstInGroupOnly)
// Only the first notification in a group plays a sound.
// Subsequent notifications added to the same group are delivered silently.
[CleverPush setGroupNotificationSoundMode:CPGroupNotificationSoundModeFirstInGroupOnly];
← SetupInbox View →
  • Basic usage
  • Mark/Unmark Subscription As Test
    • Mark Subscription As Test
    • Unmark Subscription As Test
  • Tags
  • Automatic Tag Assignment
  • Topics
  • Attributes
  • Keep Targeting Data On Unsubscribe
  • Get Device Token
  • Country & Language
  • Received Notifications
  • Tracking Notification Clicks
  • Notification Read Status
  • Remove Notification
  • App Banners
    • Custom Fonts for App Banners
    • Disabling banners
    • Non-blocking banners
    • Development mode
    • HTML Banners
  • Event Tracking
  • Follow up Events
  • Tracking Consent
  • Subscribe Consent
  • Authorization Token
  • TCF2 CMP
  • Implementation of App Banner Delegate for Displaying Banners on Custom View Controllers
  • Auto Request Notification Permission
  • Auto Resubscribe
  • Set Local Track Event Retention Days
  • Set Application Notification Badge Count
  • Handling Universal Links
  • Customizing Notification Permissions And Settings
  • Provisional Notification Authorization
  • Piano Segments
    • Set Piano Segments
    • Get Piano Segments
  • Beacon Monitoring
    • beacon integration
    • On Beacon Detection
    • Set Beacon Event Interval
    • Set Beacon Debug Scan All
  • Clear Banner Delivery Dates
    • Clear a specific banner's delivery date
    • Clear all banners' delivery dates
  • Set Group Notification Sound Mode
SDKs
JavaScriptiOSAndroidCordovaCapacitorReact NativeXamarinExpoFlutter
Community
TwitterFacebookGitHub
More
API ReferenceAPI OverviewBlogImprintPrivacy PolicyTerms of serviceGDPR
Copyright © 2026 CleverPush