Setup
Intallation
Add the required Capacitor plugin
npm install cleverpush-capacitor-sdk npx cap sync
Setup Android
- Add Firebase to your Android project. official docs
- Get your FCM Sender ID & FCM Server API Key.
- Login/Register on CleverPush
Setup iOS
Enable the required capabilities
Go to your root project and switch to the tab "Capabilities"
Enable "Push Notifications"
Enable "Background Modes" and check "Remote notifications"
Add Notification Service Extension
This is required for correctly tracking notification deliveries and for displaying big images or videos in notifications.
- Select
File>New>Targetin Xcode - Choose
Notification Service Extensionand pressNext - Enter
CleverPushNotificationServiceExtensionas Product Name, chooseObjective-Cas language and pressFinish - Press
Activateon the next prompt - Add the following at the bottom of your Podfile
target 'CleverPushNotificationServiceExtension' do pod 'CleverPush/CleverPushExtension' end- Run
pod install - Open
NotificationService.mand replace the whole content with the following:
#import <CleverPushExtension/CleverPushExtension.h> #import "NotificationService.h" @interface NotificationService () @property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver); @property (nonatomic, strong) UNNotificationRequest *receivedRequest; @property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent; @end @implementation NotificationService - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { self.receivedRequest = request; self.contentHandler = contentHandler; self.bestAttemptContent = [request.content mutableCopy]; [CleverPushExtension didReceiveNotificationExtensionRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent]; self.contentHandler(self.bestAttemptContent); } - (void)serviceExtensionTimeWillExpire { [CleverPushExtension serviceExtensionTimeWillExpireRequest:self.receivedRequest withMutableNotificationContent:self.bestAttemptContent]; self.contentHandler(self.bestAttemptContent); } @end- In the main app target → Build Phases → Embed App Extensions, keep “Copy only when installing” unchecked. Match the extension Version and Build with the main app.
- Select
Add App Group (required for delivered count,
getNotifications, and badge updates)Use the main app bundle ID, not the extension’s:
group.YOUR.BUNDLE.ID.cleverpushEnable the same App Group on both the app target and
CleverPushNotificationServiceExtension.If the dashboard Delivered count is wrong or the delivery API is never called, the Notification Service Extension is not running. Confirm:
NotificationServicecallsCleverPushExtension didReceiveNotificationExtensionRequest- The push payload includes
mutable-content - Embed App Extensions does not have “Copy only when installing” checked
- You are testing on a physical device
You can also upload an APNs Auth Key in the CleverPush channel settings instead of a
.p12certificate (see the iOS Setup page).Create your iOS push certificate
- Open Keychain Access on your Mac. (Application > Utilities > Keychain Access).
- Select Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority...
- Select the "Save to disk" option and enter any information in the required fields
- Go to the Apple developer portal, select your app and press "Edit"
- Enable "Push notifications" and press "Done"
- Go to the Create new certificate page, select "Apple Push Notification service SSL" and press "Continue"
- Select your Application Bundle ID and press "Continue"
- Press "Choose File...", select the previously generated "certSigningRequest" file and then press "Generate"
- Press "Download" and save your certificate
- Click on the downloaded .cer file, Keychain Access should open
- Select Login > My Certificates then right click on your key and click "Export (Apple Production iOS Push Services: com.your.bundle)..."
- Give the file a unique name and press save, be sure to leave the password field blank!
- Upload your certificate in the CleverPush channel settings