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

Implement system (quiet) notification to alert users there is an Ad Grant available #1660

Closed
anthonypkeane opened this issue Sep 5, 2019 · 15 comments

Comments

@anthonypkeane
Copy link

Once a month on ad grant reconciliation day alert users via a system notification (quiet notification) that they have BAT to collect.

Details on (quiet) notification: http://iosbrain.com/blog/2018/07/05/new-in-ios-12-implementing-provisional-authorization-for-quiet-notifications-in-swift/

Placeholder while I gather the details: @tmancey I will need you help spec'ing out this issue.

@anthonypkeane anthonypkeane self-assigned this Sep 5, 2019
@tmancey tmancey self-assigned this Sep 6, 2019
@kylehickinson
Copy link
Collaborator

Just to add info: We will need to schedule this before it goes out on a fixed date/time, therefore the information in that notification will be dependent on the current info at schedule time (could be days before the ads BAT distribution day)

@anthonypkeane
Copy link
Author

Just to add info: We will need to schedule this before it goes out on a fixed date/time,

Ideally we'd hook into the server and only alert users that will get ad grants. Not sure if this is feasible right now however. @tmancey can you please verify?

If we schedule a notification for users that have ads enabled, the date will be the 6th of each month at 00:00 UTC which is a few hours after the grant processing has completed.

My concern with this approach is:

  • we'll fire our system notification regardless of whether the use has an ad grant or not, and
  • we'll fire our system notification regardless of whether they have claimed that grant between processing complete time on the 5th and the notification on the 6th.

@kylehickinson
Copy link
Collaborator

kylehickinson commented Sep 6, 2019

If you want to have it be dynamically server based without relying on users being in the app to schedule it we'll need to setup a server to manage and send push notifications, but I assume this will cause privacy/security concerns since the server will have to know which device push token goes with what wallet? Likely would need discussion.

Also not entirely sure if remote notifications work with silent/provisional notifications. Would have to do some more research.

@kylehickinson
Copy link
Collaborator

@anthonypkeane Is this MVP? If not, going to remove it from the milestone

@anthonypkeane
Copy link
Author

anthonypkeane commented Sep 25, 2019 via email

@kylehickinson
Copy link
Collaborator

Thanks for the confirmation, not sure why Terry added to milestone then

@kylehickinson
Copy link
Collaborator

Needs a defined scope:

  • What are we saying in the alert
  • Where does it go when the user clicks on it
  • What happens if the user clicks it and there's no grant there (since we are just sending it every month at a given time)
  • Do we schedule it anyways if the user hasn't viewed any ads (somehow)?
  • Logic has to be in place to schedule/reschedule based on if the user enables/disables ads during the month
  • etc.…

@anthonypkeane anthonypkeane transferred this issue from brave/brave-rewards-ios Oct 15, 2019
@anthonypkeane anthonypkeane added Epic: Rewards blocked: needs info Needs further information before work can commence labels Oct 15, 2019
@kylehickinson kylehickinson added blocked If a ticket is blocked for some reason, if not using a sub-block label, please provide info in issue release-notes/exclude enhancement labels Oct 15, 2019
@anthonypkeane anthonypkeane added this to the 1.14 milestone Oct 31, 2019
@kylehickinson kylehickinson modified the milestones: 1.14, 1.15 Nov 6, 2019
@anthonypkeane anthonypkeane modified the milestones: 1.15, 1.14 Nov 6, 2019
@anthonypkeane
Copy link
Author

anthonypkeane commented Nov 14, 2019

What are we saying in the alert

TBD but for now use:

Brave Rewards Ads
Looks like you have some BAT waiting for you. Claim it now!

Where does it go when the user clicks on it

Open the browser and the Rewards Panel

What happens if the user clicks it and there's no grant there (since we are just sending it every month at a given time)

As we discussed, we should only send this notification if there is an ad grant. You mentioned checking for ad count as a way to do this.

Do we schedule it anyways if the user hasn't viewed any ads (somehow)?

No

Logic has to be in place to schedule/reschedule based on if the user enables/disables ads during the month

  • If Ads are enabled, and as soon as possible, i.e. on first open, schedule the notification to fire on the 7th of each month at 1.21 pm local time.

  • If Ads are disabled, cancel the notification

  • I need you help figuring out when to cancel the notification if no ads were shown

@jhreis jhreis removed this from the 1.14 milestone Nov 15, 2019
@anthonypkeane anthonypkeane added this to the 1.15 milestone Nov 15, 2019
@anthonypkeane
Copy link
Author

Reluctantly moving to 1.15, missing the first ad grant claim :(

@kylehickinson kylehickinson self-assigned this Nov 15, 2019
@kylehickinson
Copy link
Collaborator

I need you help figuring out when to cancel the notification if no ads were shown

What in particular do you need help with here?

@anthonypkeane
Copy link
Author

Discussion about

What in particular do you need help with here?

here: https://bravesoftware.slack.com/archives/CKA10H3AS/p1573859707000100

@anthonypkeane
Copy link
Author

anthonypkeane commented Nov 18, 2019

Update:

Trigger point for scheduling this notification:

Schedule: Any time an ad is shown, if no notification is scheduled, schedule it.
Cancel the trigger, if the user has already claimed their ad grant for that month

@anthonypkeane anthonypkeane removed their assignment Nov 18, 2019
@anthonypkeane anthonypkeane removed blocked If a ticket is blocked for some reason, if not using a sub-block label, please provide info in issue blocked: needs info Needs further information before work can commence labels Nov 18, 2019
@kylehickinson
Copy link
Collaborator

Simplified Logic:

  • Always scheduling following month based on seeing an ad in the current month (i.e. seeing an ad anytime in November, schedules for Dec 7th)
  • Claiming an ad grant cancels the current months notification if it exists (i.e. claim grant on the Dec 6th cancels any notification scheduled for Dec)

@anthonypkeane
Copy link
Author

Updated copy

Claim your Brave ad rewards
Time to get rewarded for those ads you've been seeing in Brave.

Taping should open Brave with the panel open

kylehickinson added a commit that referenced this issue 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
kylehickinson added a commit that referenced this issue 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
kylehickinson added a commit that referenced this issue 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
kylehickinson added a commit that referenced this issue Nov 20, 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
@iccub iccub added the QA/Yes label Nov 20, 2019
@iccub iccub modified the milestones: 1.15, 1.14 Nov 20, 2019
@srirambv
Copy link
Contributor

Verification passed on iPhone XR with iOS 13.2 running 1.14(19.11.22.15)

  • Verified no notification shown if there are no ads earning accumulated
  • Verified notification shows up as per test plan
    image
[Debug] [BraveRewards] > Scheduled monthly ad grant reminder: <UNNotificationRequest: 0x2966279f0; identifier: rewards.notification.monthly-claim-12, content: <UNNotificationContent: 0x280a00c30; title: <redacted>, subtitle: (null), body: <redacted>, summaryArgument: , summaryArgumentCount: 0, categoryIdentifier: , launchImageName: , threadIdentifier: , attachments: (
), badge: (null), sound: (null), realert: 0, trigger: <UNCalendarNotificationTrigger: 0x28301cf20; dateComponents: <NSDateComponents: 0x283235ef0> {
    Calendar: <CFCalendar 0x2812f4af0 [0x1fec1f5e0]>{identifier = 'gregorian'}
    Month: 12
    Day: 7
    Hour: 13
    Minute: 21, repeats: NO>>. Trigger date: Optional(2019-12-07 18:21:00 +0000)

Verification passed on iPhone 7+ with iOS 13.2 running 1.14(19.11.22.15)

  • Verified no notification shown if there are no ads earning accumulated
  • Verified notification shows up as per test plan
    image
[Debug] [BraveRewards] > Scheduled monthly ad grant reminder: <UNNotificationRequest: 0x2966279f0; identifier: rewards.notification.monthly-claim-12, content: <UNNotificationContent: 0x280a00c30; title: <redacted>, subtitle: (null), body: <redacted>, summaryArgument: , summaryArgumentCount: 0, categoryIdentifier: , launchImageName: , threadIdentifier: , attachments: (
), badge: (null), sound: (null), realert: 0, trigger: <UNCalendarNotificationTrigger: 0x28301cf20; dateComponents: <NSDateComponents: 0x283235ef0> {
    Calendar: <CFCalendar 0x2812f4af0 [0x1fec1f5e0]>{identifier = 'gregorian'}
    Month: 12
    Day: 7
    Hour: 13
    Minute: 21, repeats: NO>>. Trigger date: Optional(2019-12-07 18:21:00 +0000)

Verification passed on iPad Pro with iOS 13.2 running 1.14(19.11.22.15)

  • Verified no notification shown if there are no ads earning accumulated
  • Verified notification shows up as per test plan
    image
[Debug] [BraveRewards] > Scheduled monthly ad grant reminder: <UNNotificationRequest: 0x295f1aee0; identifier: rewards.notification.monthly-claim-1, content: <UNNotificationContent: 0x2832bdc70; title: <redacted>, subtitle: (null), body: <redacted>, summaryArgument: , summaryArgumentCount: 0, categoryIdentifier: , launchImageName: , threadIdentifier: , attachments: (
), badge: (null), sound: (null), realert: 0, trigger: <UNCalendarNotificationTrigger: 0x2808befc0; dateComponents: <NSDateComponents: 0x280b267d0> {
    Calendar: <CFCalendar 0x2829a45f0 [0x1f79bb5e0]>{identifier = 'gregorian'}
    Month: 1
    Day: 7
    Hour: 13
    Minute: 21, repeats: NO>>. Trigger date: Optional(2020-01-07 18:21:00 +0000)

Verification passed on iPad Pro with iOS 12.4 running 1.14(19.11.22.15)

  • Verified no notification shown if there are no ads earning accumulated
  • Verified notification shows up as per test plan
    image
[Debug] [BraveRewards] > Scheduled monthly ad grant reminder: <UNNotificationRequest: 0x295d04060; identifier: rewards.notification.monthly-claim-12, content: <UNNotificationContent: 0x2831f9bc0; title: Claim your Brave ads rewards, subtitle: (null), body: Time to get rewarded for those ads you've been seeing in Brave., summaryArgument: , summaryArgumentCount: 0, categoryIdentifier: , launchImageName: , threadIdentifier: , attachments: (
), badge: (null), sound: (null),, trigger: <UNCalendarNotificationTrigger: 0x280bf9060; dateComponents: <NSDateComponents: 0x283cac160>
    Calendar: <_NSCopyOnWriteCalendarWrapper: 0x280bf9d60>
    Month: 12
    Day: 7
    Hour: 13
    Minute: 21, repeats: NO>>. Trigger date: Optional(2019-12-07 07:51:00 +0000)

Verification passed on iPad Pro with iOS 12.4 running 1.14(19.11.22.15)

  • Verified no notification shown if there are no ads earning accumulated
  • Verified notification shows up as per test plan
[Debug] [BraveRewards] > Scheduled monthly ad grant reminder: <UNNotificationRequest: 0x297598570; identifier: rewards.notification.monthly-claim-12, content: <UNNotificationContent: 0x2816fdb00; title: Claim your Brave ads rewards, subtitle: (null), body: Time to get rewarded for those ads you've been seeing in Brave., summaryArgument: , summaryArgumentCount: 0, categoryIdentifier: , launchImageName: , threadIdentifier: , attachments: (
), badge: (null), sound: (null),, trigger: <UNCalendarNotificationTrigger: 0x282338620; dateComponents: <NSDateComponents: 0x281440630>
    Calendar: <_NSCopyOnWriteCalendarWrapper: 0x28233bd80>
    Month: 12
    Day: 7
    Hour: 13
    Minute: 21, repeats: NO>>. Trigger date: Optional(2019-12-07 07:51:00 +0000)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.