Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2350: Show snackbar instead of opening settings #2960

Merged
merged 4 commits into from
Nov 11, 2024

Conversation

steffenkleinle
Copy link
Member

@steffenkleinle steffenkleinle commented Oct 17, 2024

Short description

Explain that the settings have to be changed in order to enable push notifications if the permissions are denied.
Also fixes a bug that the push notifications are shown as enabled even if the permissions are denied.

Proposed changes

  • Show a snackbar if trying to enable PNs but permissions are denied
  • Correctly synchronize the app settings in PushNotificationsManager by using appContext settings

Side effects

None.

Testing

  • Push notifications are received if enabled in the settings
  • Push notifications are not received if disabled in the settings
  • If permissions are denied and the user tries to enable push notifications, a snackbar is shown
  • If permissions are granted during first app start, the setting is enabled
  • If permissions are NOT granted during first app start, the setting is disabled
  • A snackbar is shown if an error occurs during onPress (can be tested by just throwing an error there)

Resolved issues

Show snackbar instead of directly opening settings, refactor settings to

Fixes: #2350.


@@ -41,7 +43,7 @@ export const requestPushNotificationPermission = async (): Promise<boolean> => {

if (permissionStatus !== RESULTS.GRANTED) {
log(`Permission denied, disabling push notifications in settings.`)
await appSettings.setSettings({ allowPushNotifications: false })
updateSettings({ allowPushNotifications: false })
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This led to unsynchronized settings.

Copy link

codeclimate bot commented Oct 17, 2024

Code Climate has analyzed commit 30ab681 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 55.7% (50% is the threshold).

This pull request will bring the total coverage in the repository to 74.3%.

View more on Code Climate.

Copy link
Contributor

@LeandraH LeandraH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, thanks! Tested in emulated Android and real iOS

native/src/components/ExportEventButton.tsx Show resolved Hide resolved
native/src/utils/createSettingsSections.ts Outdated Show resolved Hide resolved
native/src/utils/createSettingsSections.ts Outdated Show resolved Hide resolved
Copy link
Member

@ztefanie ztefanie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for this PR.

Not tested as Leandra already did it. Only some small comments

native/src/routes/Settings.tsx Outdated Show resolved Hide resolved
native/src/routes/Settings.tsx Outdated Show resolved Hide resolved
native/src/utils/createSettingsSections.ts Outdated Show resolved Hide resolved
translations/translations.json Outdated Show resolved Hide resolved
@steffenkleinle steffenkleinle merged commit ad6c6fe into main Nov 11, 2024
9 checks passed
@steffenkleinle steffenkleinle deleted the 2350-pn-permission-settings branch November 11, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IGAPP-854: Explain opening of settings for push notification permission to user
3 participants