Pular para o conteúdo

Configurando badges para Unity

Como o plugin do Unity não contém o cabeçalho PWNotificationExtensionManager, você precisa executar algumas etapas adicionais para implementar Badges em seu projeto Unity.

1. Adicione a Notification Service Extension (File -> New -> Target…)

Anchor link to

2. Selecione a “Notification Service Extension”

Anchor link to

3. Adicione o Pushwoosh.xcframework ao destino da extensão NotificationService da seguinte forma:

Anchor link to
  1. Escolha o destino da extensão NotificationService.
  2. Vá para a aba “General”.
  3. Encontre ‘Framework and Libraries’ e pressione o botão ’+’.
  4. Selecione Pushwoosh.xcframework.

4. Atualize o código da Notification Service Extension da seguinte forma:

Anchor link to
#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. Adicione a “App Groups Capability” para cada destino do seu aplicativo

Anchor link to
App Groups Capability Info.plist

6. Adicione o ID dos App Groups ao seu info.plist para cada destino do seu aplicativo

Anchor link to
<key>PW_APP_GROUPS_NAME</key>
<string>group.com.example.demoapp_example</string>

Compartilhe seu feedback conosco

Anchor link to

Seu feedback nos ajuda a criar uma experiência melhor, então adoraríamos ouvir de você se tiver algum problema durante o processo de integração do SDK. Se você enfrentar alguma dificuldade, não hesite em compartilhar suas opiniões conosco através deste formulário.