104 posts were split to a new topic: Temp topic - do not reply
EXAMPLE 7
(added June 2025)
Google Apps Script, the Web component and a timer
Prerequisites:
- a standalone Google Apps Script
- deployed for Anyone to execute
function doGet(e) {
const scriptProperties = PropertiesService.getScriptProperties();
if (e.parameter.do == "get") {
const message = scriptProperties.getProperty('message');
return ContentService.createTextOutput(message);
}
else if (e.parameter.do == "set") {
scriptProperties.setProperty('message', e.parameter.message);
}
}
Setup:
- with the example aia, you will need to add your google apps script url in the blocks, in two places.
Blocks (using the new melon notification blocks)
AIA (blank)
GASMessage_iToo_blank.aia (151.6 KB)
Comment:
With the Google Apps Script open to the Execution Log, you can watch the calls being made by iToo every 15 seconds. Probably not the best method for an intensive call routine. Quotas for running a google apps script (on a consumer account) would allow for @ 87 users per day, if calling every 15 seconds, or up to 50,000 users if calling only 1 time per day. With a workspace account, this increases to 500,000 users for one call per day.
SUMMARY
Well, there you are, six (now seven) different ways to get push notifications running in your app, at relatively no cost.
I am slightly uncomfortable about the timer approach, because this is always calling data back to be tested in the background process, there are polling routines for php, and triggers for mysql, but integrating these would be a headache, let us keep it simple. I also considered a version for going direct to my redis server using webdis (SEE HERE), but the setup is onerous, and again, let us keep it simple. If anyone has a better solution, I am all ears.
Which one is best ?
This will all depend on your circumstances, what you may have already available, and what you consider to be free (free as in beer...). The Google Sheet/Form approach seems best on this front, but if you have your own online server, then this may be better. It will all come down to what works for you.
I ran a test on Firebase, after leaving the app running for @ 12 hours, and checked the data usage. Calculating it out, it seems that your app could make @ 1 million calls before reaching the 360mb free limit per project, so one call per user per day = 1 million users. Should be enough?
Battery usage on device?
Lots of discussion about this. I am yet to see any significant change to my device battery levels as a result of running this service, either with dataChanged or with a timer.
Support
I have assumed that you have sufficient knowledge with regarding to Google/php/mysql/Firebase to get these examples working, most questions about these web technologies will probably be off-topic, any questions therefore should be about the specifics of using these examples.
Updates
The itoo
and notificationStyle
extensions have now been updated for Android 14 users / API 34.
Update 2024-12-21
I have now tested with the latest itoo (v4.4) and the new melonNotification extension (v1.1). The examples continue to work but you will need to make some changes to the blocks.
Update 2025-06-05
Most examples now tested and working with itoo 4.4.1 and MelonNotification 1.2
7th example added using Google Apps Script & Script Properties
For all examples (except Example 7), make the following changes:
Replace
with
and replace this notificationStyle block
with these two melonNotification blocks
add the melonnotification extension to your downloaded project example before removing the notificationStyle extension, so that you can see where everything needs to be replaced.
note the basic icon contains a colon at the start - ":ic_dialog_alert"
Continued thanks to @Kumaraswamy for his help and support
If any other such issues arise, then please report here or in the respective topics.
Thank you for the fantastic work. This has given me an idea to address the issues Android 14 users face when using iToo. We could use an Alarm Manager to periodically check for updates in the Google Sheet throughout the day and if at a certain alarm an update is available, the system would send a notification. This setup allows you to continue using Alarm Manager as usual, simply by adding a new Alarm Manager item.
Thanks alot for your great efforts
The app crashes when i use timer only when i changed the target sdk to 34
Tested in android 14 Samsung A04s
Ensure you update your itoo and notification style extensions to the very latest version that work with API 34 and android 14. Remember, that you need to compile, this will not work with companion.
For now, use this update v4.3:
Example 1: App closes immediately. Device running on Android 11 and itoo version 4.3.1
Did you use the latest NotificationStyle extension as well ?
Yes
I don't get a crash, but I also do not get any response. Tested Android 12 and 14.
[EDIT - oops! forgot to build - will test again]
The original apks I created and tested are still working OK on Android 13 Pixel 4a, but if I attempt to create a new apk from the aia file, then this does not work (using either the previous extensions or the most recent), this tested on Android 12, 13 and 14.
I'll be running logcat to see what is occuring.
In the meantime test this aia project (build it first, of course), should just show that itoo and notficationStyle is working.
SimpleItooProject2 (1).aia (117.1 KB)
All the other examples appear to work on Android 12 and 14 for me, it is just the one with the Firebase dataChanged event causing an issue. It is being investigated.
Have now figured out the problem.
Set your firebase project rules as follows:
{
// Allow read/write access to all users under any conditions
// Warning: **NEVER** use this ruleset in production; it allows
// anyone to overwrite your entire database.
"rules": {
".read": true,
".write": true
}
}
In the end, it was a simple fix, (and I probably should have done this in the first place!) whilst allowing the itoo node to be read/write true and have other nodes with secure rules.
In the Execution Script, simply add itoo
to the end of the firebase url.
Edits have been made to the Example 1 post.
In these examples, will the permanent service notification be shown?
Yes, because these use the CreateProcess method
Taifun