Saltar al contenido

Configuración de badges para Flutter

1. Abra su proyecto de iOS ubicado en your_project/ios/Runner.xcworkspace y cree una NotificationServiceExtension:

2. Abra el Podfile (ubicado en your_project/ios/Podfile) y agregue la dependencia PushwooshXCFramework para el NotificationServiceExtensionTarget:

target ‘NotificationService’ do
pod ‘PushwooshXCFramework’, ‘>=6.5.0’
end

3. Instale los pods a través de la Terminal:

cd ios && pod install

4. Cierre y vuelva a abrir su proyecto de Xcode.

5. Asegúrese de que su Deployment target coincida con el del Runner target; de lo contrario, podría enfrentar un problema al compilar su aplicación (por ejemplo, si especifica iOS 10.0 en los targets de Runner y iOS 15.5 en los de NotificationService).

6. Agregue la capacidad App Groups a los targets de Runner y NotificationService y agregue un nuevo grupo con el mismo nombre para ambos targets:

7. Agregue la bandera PW_APP_GROUPS_NAME de info.plist a los targets de Runner y NotificationService con el nombre del grupo como su valor de cadena:

8. Vaya a NotificationService.m y reemplace su código con lo siguiente:

#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

¡Eso es todo!

Comparta sus comentarios con nosotros

Anchor link to

Sus comentarios nos ayudan a crear una mejor experiencia, por lo que nos encantaría saber de usted si tiene algún problema durante el proceso de integración del SDK. Si encuentra alguna dificultad, no dude en compartir sus opiniones con nosotros a través de este formulario.