Ok, I have Taifun's alarmmanager extension. And what I have to do?
Taifun said I need to ask here. So I wanna set push notification on 25th day of every month.
He told me that I need get the instant of the 25th of the current month and if today is > that day, then add 1 month, see the methods of the clock component, then use that instant in the Start method of the alarmmanager extension together with interval MONTH.
Could anyone help me? The more I think about it, the more I complicate it.
ok, I gave you some tips how to solve it... what did you try? please show your blocks?
trying something helps you to learn rather than just asking for the solution...
use Do it to debug your blocks, see also tip 4 here https://puravidaapps.com/learn.php
see also Live Development, Testing, and Debugging Tools
Taifun
Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.
Ok, thank you @Taifun
I thought a lot how to set it up. And...
- Switch is turning on/off push notification but need to click on save button to save result.
- When app starts it's need to read from database last saved result to switch "switch" in right position.
I try to do it the easiest as I can. I still don't get my wanted result.
I've tried but can't do it. I know I set blocks wrong. I have no idea how do that...
it looks like you forgot to read the documentation of the clock component and methods...
http://ai2.appinventor.mit.edu/reference/components/sensors.html#Clock
here is a running example
this method returns an instant of the next 25th, so if the 25th already passed in the current month, then the 25th of the following month will be returned, the hour is 9am
month25.aia (2.4 KB)
Taifun
Hmm... I've been working on it for another day and even thanks to your tips there is still some error.
I am attaching blocks and a screenshot.
On screenshot I can see "Bad arguments to Enabled".
I think it is argument from the clock. Am I right? Can I just add call.Clock1.FormatDateTime. to instant of call.TajfunsAlarmManager1.Start ? Maybe I have to make a new procedure?
your Enabled error message seems to be something else... when exactly does the error occur? check your Enabled blocks...
and you might want to fix this
as it seems to be you really did not understand what you are doing
I only used the FormatDateTime block in the example to show you how the result looks like...
Taifun
@Taifun & @Anke I really don't know any programming language. Just started learn JAVA, next will be JS. In past I learned HTML and C++ but this was 20y ago. Then I decided that I did not need them. I have practically forgotten them. Today, older, a bit smarter, I want to develop a little. The app is for the local community, and for my fun.
I created the "on_off" procedure on the basis of another procedure, which I believe was supposed to set the switch to the right position, depending on the data stored in the database.
Indeed, I do not fully understand the principle of operation of the blocks. I move here intuitively. But I want to learn.
as @Anke tried to explain... to set the global variable switch to an empty list does not make sense... this should be a boolean true or false block depending on the initial value of your switch
Taifun
I know I'm closer with your helps.
I made something like this:
But still don't work.
Which block i need to use to initialize global "switch"? Is text string ok?
Or something like this:
Please don't laugh
no
Taifun...
well, I guess you answered your question yourself...
so what is the initial value of your switch? is it true? Is it false? depending on that initial value, let's assume the initial value is true, then you set your variable to true.
Taifun
Well, In database initial when TagNotThere is true, and initial in designer is true to (for switch?). And now I'm lost. Save button don't save position or initial don't get right position from database.
Please don't laugh again
@Anke Thank you, I have notifications working after many bugs.
@Taifun Thank You too.
I owe you both a bottle of scotch.
One more question. How to initiate a specific screen after clicking on push notification? I thought it would be successful, but unfortunately not ...
And is small icon have to be in jpg or png? Which format would I use, it still displays a gray square instead of an icon.
the AfterAlarm event only fires if the app is up and running, see also the documentation App Inventor Extensions: Alarm Manager | Pura Vida Apps
Event indicating that an alarm occurred. Event will fire only if the app is up and running, else a notification will be displayed. For multiple screen apps this happens only for those screens, the extension is being used or has been dragged to the working area.
you will have to use the Screen.Initialize event like this
if not is empty get plain start text
then open another screen "your screen name"
the not block is in the logic drawer
the is empty block is in the text drawer
the get plain start text block is in the controls drawer
see also The recommended method of switching screens in App Inventor
what about reading the documentation?
Sets SmallIcon for notification. Recommended size is 96x96.
Note : this feature is available starting rom Android 6 (API Level 23). For older devices this setting will be ignored. The small icon must be in png format and have a transparent background.
Taifun