Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Fix #1660: Show monthly ad grant reminders #1988

Merged
merged 1 commit into from
Nov 20, 2019

Conversation

kylehickinson
Copy link
Collaborator

@kylehickinson kylehickinson commented Nov 19, 2019

These notifications are scheduled based on when a user sees ads are always scheduled for the following month. They are only cancelled if the user successfully claims an ad grant

Summary of Changes

This pull request fixes issue #1660

Submitter Checklist:

  • Unit Tests are updated to cover new or changed functionality
  • User-facing strings use NSLocalizableString()

Test Plan:

  • Prefix: Only works on device, couldn't seem to get it working on simulator? YMMV
  • Enable rewards
  • Visit a site (i.e. imdb.com)
  • Wait 2m and see an ad
  • Change the date to the next 7th (in this case Dec 7) at 1:20pm
  • Wait 1m, verify that a provisional notification appears on your lock-screen
  • Verify tapping on that notification opens the app and brings up the users

Reviewer Checklist:

  • Issues include necessary QA labels:
    • QA/(Yes|No)
    • release-notes/(include|exclude)
    • bug / enhancement
  • Necessary security reviews have taken place.
  • Adequate unit test coverage exists to prevent regressions.
  • Adequate test plan exists for QA to validate (if applicable).
  • Issue is assigned to a milestone (should happen at merge time).

Sorry, something went wrong.

@kylehickinson kylehickinson force-pushed the quiet-monthly-notification branch 2 times, most recently from 3fa3e45 to bf54017 Compare November 19, 2019 20:09
@kylehickinson kylehickinson marked this pull request as ready for review November 19, 2019 20:52
Copy link
Contributor

@iccub iccub left a comment

Choose a reason for hiding this comment

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

I feel like we should set Calendar to always use gregorian format.
In the past we had few date related bugs in DAU that happened because Arabic and Japanese calendars were used by users

Since Date() is locale independent, just changing the calendar alone should be enough to prevent bugs, might need to do more research on it though, esp with handling next month logic

Let me know what do you think about it

return
}
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.provisional, .alert, .sound, .badge]) { (granted, error) in
Copy link
Contributor

Choose a reason for hiding this comment

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

Can drop brackets around granted, error

content.body = Strings.MonthlyAdsClaimNotificationBody

let trigger = UNCalendarNotificationTrigger(
dateMatching: .init(month: month, day: 7, hour: 13, minute: 21),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this date precisely? Will it work correctly for 12-hour formats with the hour = 13?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@iccub Basically just was asked for that to be the time it goes off in the ticket (1:21pm or 13:21 in 24-hour clocks). But yes, it definitely works with 12 hour formats, tested on my device which is in 12-hour mode

/// this would return `1` for January.
static private func nextMonth() -> Int? {
guard let nextMonthsDate = Calendar.current.date(byAdding: .month, value: 1, to: Date()) else {
// Apocalypse...
Copy link
Contributor

Choose a reason for hiding this comment

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

what about assertionFailure("Apocalypse")

@iccub
Copy link
Contributor

iccub commented Nov 20, 2019

Some tests

Zrzut ekranu 2019-11-20 o 13 40 16

These notifications are scheduled based on when a user sees ads are always scheduled for the following month. They are only cancelled if the user successfully claims an ad grant
@kylehickinson kylehickinson force-pushed the quiet-monthly-notification branch from bf54017 to f6ed34e Compare November 20, 2019 16:20
Copy link
Contributor

@iccub iccub left a comment

Choose a reason for hiding this comment

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

Good job 🇯🇵

@kylehickinson kylehickinson merged commit 5eab26a into development Nov 20, 2019
@kylehickinson kylehickinson deleted the quiet-monthly-notification branch November 20, 2019 16:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants