Skip to content

Commit

Permalink
Hack to set the HasRequestedNotificationPermission
Browse files Browse the repository at this point in the history
If it is not set and the user has consented
This fixes
e-mission/e-mission-docs#1094 (comment)
  • Loading branch information
shankari committed Oct 9, 2024
1 parent 1c417e8 commit 3a7b6b4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ios/BEMDataCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ - (id)settingForKey:(NSString*)key

- (void)initWithConsent {
self.tripDiaryStateMachine = [TripDiaryStateMachine instance];
// Backwards compat hack to ensure that, if an existing user, with a user
// who installed the app before we started filling in
// `HasRequestedNotificationPermission` flag, and tries to re-enable
// notifications after disabling them through the settings
// https://github.com/e-mission/e-mission-docs/issues/1094#issuecomment-2403052620
if (![[NSUserDefaults standardUserDefaults] boolForKey:HAS_REQUESTED_NOTIFS_KEY]) {
// before version 1.9.0, notifications were required. So if the user consented,
// we must have requested notifications
// after version 1.9.0, we always set it before showing the notification,
// so we should never get here after 1.9.0
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:HAS_REQUESTED_NOTIFS_KEY];
}
[SensorControlBackgroundChecker checkAppState];
NSDictionary* emptyOptions = @{};
[AppDelegate didFinishLaunchingWithOptions:emptyOptions];
Expand Down

0 comments on commit 3a7b6b4

Please sign in to comment.