Настройка бейджей для Flutter
- Откройте ваш iOS-проект, расположенный в your_project/ios/Runner.xcworkspace, и создайте NotificationServiceExtension:


- Откройте Podfile (расположенный в your_project/ios/Podfile) и добавьте зависимость PushwooshXCFramework для NotificationServiceExtensionTarget:
target ‘NotificationService’ do pod ‘PushwooshXCFramework’, ‘>=6.5.0’end- Установите pod’ы через Терминал:
cd ios && pod install- Закройте и снова откройте ваш проект Xcode.
-
Убедитесь, что ваш Deployment target совпадает с target в Runner; в противном случае вы можете столкнуться с проблемой при сборке приложения (например, если вы укажете iOS 10.0 в Runner и iOS 15.5 в NotificationService target).
-
Добавьте возможность App Groups к target’ам Runner и NotificationService и добавьте новую группу с одинаковым именем для обоих target’ов:


- Добавьте флаг PW_APP_GROUPS_NAME в info.plist для target’ов Runner и NotificationService, указав имя группы в качестве его строкового значения:

- Перейдите в NotificationService.m и замените его код на следующий:
#import “NotificationService.h”#import <Pushwoosh/PWNotificationExtensionManager.h>
@interface NotificationService ()<strong>@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);</strong>@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Поделитесь с нами своим мнением
Anchor link toВаши отзывы помогают нам улучшать продукт, поэтому мы будем рады, если вы поделитесь с нами информацией о любых проблемах, возникших в процессе интеграции SDK. Если вы столкнетесь с какими-либо трудностями, пожалуйста, не стесняйтесь поделиться своими мыслями с нами через эту форму.