Настройка бейджей для Cordova
Поскольку плагин для Cordova не содержит заголовок PWNotificationExtensionManager
, для внедрения бейджей в ваш проект Cordova необходимо выполнить несколько дополнительных шагов. Вот что вам понадобится для настройки бейджей:
- Создать расширение службы уведомлений (Notification Service Extension)
- Добавить фреймворк Pushwoosh
- Добавить возможность App Groups
1. Добавьте расширение службы уведомлений (Notification Service Extension) (File -> New -> Target…)
Anchor link to
2. Выберите “Notification Service Extension”
Anchor link to
3. Добавьте Pushwoosh.xcframework в таргет расширения NotificationService следующим образом:
Anchor link to- Выберите таргет расширения NotificationService.
- Перейдите на вкладку “General”.
- Найдите раздел ‘Framework and Libraries’ и нажмите кнопку ’+’.
- Выберите Pushwoosh.xcframework.


4. Обновите код расширения службы уведомлений следующим образом:
Anchor link to#import "NotificationService.h"#import "PWNotificationExtensionManager.h"
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { self.contentHandler = contentHandler; self.bestAttemptContent = [request.content mutableCopy];
[[PWNotificationExtensionManager sharedManager] handleNotificationRequest:request contentHandler:contentHandler];}
- (void)serviceExtensionTimeWillExpire { // Called just before the extension will be terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. self.contentHandler(self.bestAttemptContent);}
@end
5. Добавьте “App Groups Capability” для каждого таргета вашего приложения
Anchor link to


6. Добавьте App Groups ID в ваш файл info.plist для каждого таргета вашего приложения
Anchor link to<key>PW_APP_GROUPS_NAME</key><string>group.com.example.demoapp_example</string>
Поделитесь с нами своим мнением
Anchor link toВаши отзывы помогают нам улучшать наши продукты, поэтому мы будем рады, если вы расскажете нам о любых проблемах, возникших в процессе интеграции SDK. Если вы столкнетесь с какими-либо трудностями, пожалуйста, поделитесь с нами своими мыслями через эту форму.