Skip to content

Commit

Permalink
Ensure push notification confirmation dialog follows ATT confirmation…
Browse files Browse the repository at this point in the history
… dialog

As the AppsFlyer team mentions, the AppsFlyer SDK should be initialized as soon as possible to collect potential events. Therefore, we initialize the AppsFlyer SDK first. However, before that, we need to display the ATT confirmation dialog. Only after that should we show the push notification confirmation dialog. This sequencing is necessary because iOS does not allow multiple native dialogs to be displayed simultaneously. If we attempt to open a native dialog while another is already on the screen, the system forcefully closes the previous dialog, as mentioned here: [https://pub.dev/packages/app_tracking_transparency#important-notice].
  • Loading branch information
sultanmyrza committed Feb 22, 2024
1 parent 9e9c887 commit 8ef8185
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,14 @@ export class AppComponent {
private readonly inAppStoreService: InAppStoreService,
private readonly zone: NgZone,
private readonly router: Router,
appsFlyerService: AppsFlyerService,
notificationService: NotificationService,
pushNotificationService: PushNotificationService,
langaugeService: LanguageService,
diaBackendAuthService: DiaBackendAuthService,
diaBackendNotificationService: DiaBackendNotificationService,
uploadService: DiaBackendAssetUploadingService
private readonly appsFlyerService: AppsFlyerService,
private readonly notificationService: NotificationService,
private readonly pushNotificationService: PushNotificationService,
private readonly langaugeService: LanguageService,
private readonly diaBackendAuthService: DiaBackendAuthService,
private readonly diaBackendNotificationService: DiaBackendNotificationService,
private readonly uploadService: DiaBackendAssetUploadingService
) {
appsFlyerService.initAppsFlyerSDK();
notificationService.requestPermission();
pushNotificationService.register();
langaugeService.initialize();
diaBackendAuthService.initialize$().pipe(untilDestroyed(this)).subscribe();
uploadService.initialize$().pipe(untilDestroyed(this)).subscribe();
diaBackendNotificationService
.initialize$()
.pipe(untilDestroyed(this))
.subscribe();
this.inAppStoreService.initialize();
this.initializeApp();
this.initializeDeepLinking();
this.restoreAppState();
Expand All @@ -84,6 +73,21 @@ export class AppComponent {
await this.platform.ready();
AppComponent.setDarkMode(true);
await SplashScreen.hide();

await this.appsFlyerService.initAppsFlyerSDK();
this.notificationService.requestPermission();
this.pushNotificationService.register();
this.langaugeService.initialize();
this.diaBackendAuthService
.initialize$()
.pipe(untilDestroyed(this))
.subscribe();
this.uploadService.initialize$().pipe(untilDestroyed(this)).subscribe();
this.diaBackendNotificationService
.initialize$()
.pipe(untilDestroyed(this))
.subscribe();
this.inAppStoreService.initialize();
}

async initializeDeepLinking() {
Expand Down

0 comments on commit 8ef8185

Please sign in to comment.