Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

feat(Android): add all alarm types to trigger alarmManager#749

Merged
helenaford merged 8 commits into
invertase:mainfrom
meypod:android_add_all_alarm_types
Jun 13, 2023
Merged

feat(Android): add all alarm types to trigger alarmManager#749
helenaford merged 8 commits into
invertase:mainfrom
meypod:android_add_all_alarm_types

Conversation

@meypod

@meypod meypod commented Apr 16, 2023

Copy link
Copy Markdown
Contributor

resolves #655

hi @helenaford
I tried to change all places I thought I should for this change, still I may have missed something
please let me know if there's any problem

@meypod

meypod commented Apr 16, 2023

Copy link
Copy Markdown
Contributor Author

Also I'm on windows and I didn't manage to use scripts or run E2E tests, I only managed to run jest tests

@codecov

codecov Bot commented Apr 16, 2023

Copy link
Copy Markdown

Codecov Report

Merging #749 (134cbae) into main (ac1645f) will increase coverage by 0.08%.
The diff coverage is 90.91%.

@@            Coverage Diff             @@
##             main     #749      +/-   ##
==========================================
+ Coverage   77.25%   77.33%   +0.08%     
==========================================
  Files          34       34              
  Lines        1701     1711      +10     
  Branches      566      569       +3     
==========================================
+ Hits         1314     1323       +9     
- Misses        337      338       +1     
  Partials       50       50              

@meypod

meypod commented Apr 16, 2023

Copy link
Copy Markdown
Contributor Author

Oh I see I have to write a db migration, I'm not sure if I can do that
will try at some time later

@meypod

meypod commented Apr 16, 2023

Copy link
Copy Markdown
Contributor Author

again: Oh I see I don't have to 😅 the trigger object is saved in bytes and is retrieved at some point later

@helenaford

helenaford commented Apr 26, 2023

Copy link
Copy Markdown
Contributor

thanks for the contribution 💯 very grateful. would you be able to add some more notes about the api changes or what the api would now look like i.e. how would a developer use this new functionality? It will help when reviewing the p/r.

OK, I've looked more into your p/r and I love the changes! To help with the review, can you give some more detail on why you need this change and/or a use case(s)?

notificationModel.getId().hashCode(),
launchActivityIntent,
mutabilityFlag);
AlarmManagerCompat.setAlarmClock(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do you need to set pendingLaunchIntent for type SET_ALARM_CLOCK and not for the other types?

@meypod meypod Apr 27, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

from what I remember, when using the setAlarmClock api, it may show an alarm icon in some versions and devices, that when you touch the icon, it will use the pending intent. and so I remember it being mandatory. I'm not sure if it is, but as far as I remember, it was required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

so Even if it is not required, I'd like the icon to launch the app that has caused it to appear (as it is common UX for alarm apps I believe).

@meypod

meypod commented Apr 27, 2023

Copy link
Copy Markdown
Contributor Author

well I use notifee in my app (al-azan) as the core functionality of setting alarms for specific times (to make it super simple, my app is an alarm clock that adjusts It's time everyday)
the launch intent, custom components and custom alarm types are the main features of notifee that are important to me

the reason for different alarm type is because depending on how you use them, they have different set of behaviors. and I think having setAlarmClock gives highest guarantee of delivery at the exact given time. Also it's what is recommended when you are setting an Alarm that is user-facing. but setAlarmClock was giving my Google Pixel users a bit of headache by messing up their adaptive charging feature. that's where I needed to use the setExactAndAllowWhileIdle by providing an option in my app UI. and so I came up with this PR. before this, I was simply changing the allowWhileIdle to always use setAlarmClock in my own branches of the notifee, that's why I never made a PR for it before.

@meypod

meypod commented Apr 27, 2023

Copy link
Copy Markdown
Contributor Author

also I remember adding some notes to the library for the new usage, correct me if I have forgotten to
if there's anything else I have to add, please tell me

also I tried to make it a non breaking change, this shouldn't break existing apps

@nateshmbhat

nateshmbhat commented May 13, 2023

Copy link
Copy Markdown
Contributor

when can this PR be merged ? 🙏🏻 @helenaford

@github-actions

Copy link
Copy Markdown

Hello 👋, this PR has been opened for more than 2 months with no activity on it.

If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing!

You have 15 days until this gets closed automatically

@github-actions github-actions Bot added the Stale label Jun 12, 2023
@meypod

meypod commented Jun 12, 2023

Copy link
Copy Markdown
Contributor Author

comment

@github-actions github-actions Bot removed the Stale label Jun 12, 2023
@helenaford helenaford merged commit e2f4139 into invertase:main Jun 13, 2023
@helenaford

Copy link
Copy Markdown
Contributor

thank you, merged 🙏

//...
alarmManager: {
allowWhileIdle: true,
type: AlarmType.SET_EXACT_AND_ALLOW_WHILE_IDLE,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

from https://developer.android.com/develop/background-work/services/alarms/schedule#repeating:

A poorly-designed alarm can cause battery drain and put a significant load on servers. For this reason, on Android 4.4 (API level 19) and higher, all repeating alarms are [inexact alarms](https://developer.android.com/develop/background-work/services/alarms/schedule#inexact).

Would be nice if this is documented somewhere

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.

[Feature]: add option for all alarm types

4 participants