Skip to content

Настройка бейджей для Unity

Поскольку плагин Unity не содержит заголовок PWNotificationExtensionManager, для внедрения бейджей в ваш проект Unity необходимо выполнить несколько дополнительных шагов.

1. Добавьте Notification Service Extension (File -> New -> Target…)

Section titled “1. Добавьте Notification Service Extension (File -> New -> Target…)”

2. Выберите “Notification Service Extension”

Section titled “2. Выберите “Notification Service Extension””

3. Добавьте Wavesend.xcframework в таргет расширения NotificationService следующим образом:

Section titled “3. Добавьте Wavesend.xcframework в таргет расширения NotificationService следующим образом:”
  1. Выберите таргет расширения NotificationService.
  2. Перейдите на вкладку “General”.
  3. Найдите раздел ‘Framework and Libraries’ и нажмите кнопку ’+’.
  4. Выберите Wavesend.xcframework.

4. Обновите код Notification Service Extension следующим образом:

Section titled “4. Обновите код Notification Service Extension следующим образом:”
#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” для каждого таргета вашего приложения

Section titled “5. Добавьте “App Groups Capability” для каждого таргета вашего приложения”
Возможность App Groups Info.plist

6. Добавьте App Groups ID в ваш info.plist для каждого таргета вашего приложения

Section titled “6. Добавьте App Groups ID в ваш info.plist для каждого таргета вашего приложения”
<key>PW_APP_GROUPS_NAME</key>
<string>group.com.example.demoapp_example</string>

Поделитесь с нами своим мнением

Section titled “Поделитесь с нами своим мнением”

Ваши отзывы помогают нам улучшить наш продукт, поэтому мы будем рады, если вы расскажете о любых проблемах, возникших в процессе интеграции SDK. Если вы столкнетесь с какими-либо трудностями, пожалуйста, поделитесь с нами своими мыслями через эту форму.