Einrichten von Badges für Flutter
1. Öffnen Sie Ihr iOS-Projekt unter your_project/ios/Runner.xcworkspace und erstellen Sie eine NotificationServiceExtension:


2. Öffnen Sie die Podfile (unter your_project/ios/Podfile) und fügen Sie die PushwooshXCFramework-Abhängigkeit für das NotificationServiceExtensionTarget hinzu:
target ‘NotificationService’ do pod ‘PushwooshXCFramework’, ‘>=6.5.0’end3. Installieren Sie die Pods über das Terminal:
cd ios && pod install4. Schließen Sie Ihr Xcode-Projekt und öffnen Sie es erneut.
5. Stellen Sie sicher, dass Ihr Deployment-Ziel mit dem im Runner-Ziel übereinstimmt; andernfalls könnten beim Erstellen Ihrer App Probleme auftreten (z. B. wenn Sie iOS 10.0 im Runner- und iOS 15.5 im NotificationService-Ziel angeben).
6. Fügen Sie die App Groups-Fähigkeit sowohl zum Runner- als auch zum NotificationService-Ziel hinzu und fügen Sie für beide Ziele eine neue Gruppe mit demselben Namen hinzu:


7. Fügen Sie das PW_APP_GROUPS_NAME info.plist-Flag sowohl zum Runner- als auch zum NotificationService-Ziel hinzu, mit dem Gruppennamen als String-Wert:

8. Gehen Sie zu NotificationService.m und ersetzen Sie den Code durch den folgenden:
#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);}@endDas ist alles!
Teilen Sie Ihr Feedback mit uns
Anchor link toIhr Feedback hilft uns, eine bessere Erfahrung zu schaffen. Wir würden uns daher freuen, von Ihnen zu hören, wenn Sie während des SDK-Integrationsprozesses auf Probleme stoßen. Sollten Sie auf Schwierigkeiten stoßen, zögern Sie bitte nicht, uns Ihre Gedanken über dieses Formular mitzuteilen.