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


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


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

8. Перейдите в 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. Если вы столкнетесь с какими-либо трудностями, пожалуйста, не стесняйтесь поделиться своими мыслями с нами через эту форму.