this app is to serve push notifications for a game that i play.
its a web browser based game, and doesn't offer push notifications natively.
So the goal of this app is to read the persons api response, and create notifications based on it.
The only thing provided by the api though is a timestamp of when the thing was started. i have to do the math to figure out when it will end.
i want this happening in the background on its own. So that the person always recieves the notifications. And additionally, the app simply references the itoo information that i save when processing the data. That way the data is always up to date, and is updating on a regular interval (which will be 5 minutes once i confirm that the background process is actually happening, and then set to a custom number by the user later after that.)
Then i just plug the timestamp into the alarm manager as an instant, and bang. push notification.
thats kind of the basic over view, let me know if you need more detail.
For short time intervalls (below 15 minutes) my suggestion is to use itoo together with a clock and the melon notification extension
If you like to continue using the alarmmanager extension and start an alarm via itoo as you are trying to doi it from your latest screenshot, you will have to fix your blocks like this:
In your procedure background _procedure there are 3 things missing: 1) the argument x
For the main background procedure, you need to include an argument "x".
a statement
evaluate but ignore result TaifunAlarmManager1
A component does not get created until you touch any of its block
and 3) as you are using the web component to get some data from the api, you also should register a Web1 GotText event and create a corresponding event handler for rhat
Also in your test project don't use a clock to start the same alarm every 10 seconds again amd again, start it only once and be patient until the notification gets diplayed
For your test project you only have to ask for post notification permission and optionally schedule exact alarm permission
Fir debugging add Notifier LogInfo methods into your blocks and use logcat to check
most of what you explained here i have already. with the exception of the "x" value. which i have now added.
However. My issue is that i cannot get the alarm manager to post a notification at all.
after your suggestion about the "now" instant, i've added 30 seconds to it in the hopes that it would come through. But no luck so far.
To clarify. I have used the melon notifications, but it wasn't working from the background, which i suspect was because i was missing that "x" argument.
would still love if you would explain where i'm going wrong with the notifications from the alarm manager though.
I've put it into a manual button for the moment for testing. But i'm not getting the notification.
And i have looked through your examples several times... im sorry to say i am just failing to notice where my mistake is. if you need more blocks let me know
What about trying my simple test project from the download folder?
From your screenshot it looks like you forgot to ask for post notification permission. Also use event Started to see, if the alarm has been set correctly... Btw. an index in App Inventor starts with 1, so I would use id = 1 instead of 0...
Then close the app and wait for the notification
EDIT: use the close application method for that. Remember, if you do not close the app and the app is still running at alarm time, then event AfterAlarm gets triggered...
Default is inexact alarms, so be a bit patient until you get the notification or ask additionally for schedule exact alarm permission
Note : Google recommends to use exact alarms wisely to reduce battery consumption. See also Use cases that might not require exact alarms. If you decide to use exact alarms, then the user needs to grant the SCHEDULE_EXACT_ALARM permission, see method AskForScheduleExactAlarmPermission
Btw. which device and Android version are you using for your tests?
Taifun
I'll try to address each part in the same order your presented it.
at the time of this post i haven't tried the test project yet. But I'll add that to my list today when i get a chance to sit.
I am asking for all the permissions, because i was unsure at the time if one of the other permissions was needed for the notification to post.
And the itoo process is starting (the notification is posting in the top bar). You addressed it earlier, and i think i fixed the process by adding the "x argument". But again havn't sat down to test it. Was a busy day yesterday.
I've fixed the index you mentioned, and will note that for later. My brain always says 0 for lists xD
And I'm using the "exact alarms" i think, unless there is an additional step after asking for the permission?
My current device for testing is my personal device, as this is the device i had planned to mainly use the app on.
is the "open above lockscreen feature" limited only to alarms(can only be triggered by alarms), or can that be triggered by a stimulant, say when bytes/strings are received by a BLE module?
i believe that feature also brings the app to the foreground if im not wrong?
im trying to trigger an alarm using itoo and ble and it works, but not in a way i expect it to work. instead of anything appearing on the lockscreen, i get only a notification with the title and text. i created another screen for lockscreen but it doesnt appear. i tried to follow the lockscreen app as much as i could, and the lockscreen app works perfectly fine, but this doesnt. i dont understand where the issue is. (even if the alarm activates because of ble received, the alarm still should perform as expected right?) all permissions required have been enabled as well.
is it because itoo is interfering with the app with the createprocess block?
ALSO: in recent xiaomi mobile phones, theres an additional show in lockscreen option that needs to be enabled by opening app settings. (advice)
if i put the instant to call clock1.now, will the alarm activate just after the button is pressed?
if yes, then it doesnt work somehow for me{i created an apk of the lockscreen example file, and tweaked only that function a bit},
and if no, then how does it work, and what does that sentence entail?
if i want to trigger an alarm as soon as the button is pressed{button.click or idk}, how do i do so?
To solve the issue I think I could add some logic to not use the alarmmanager api in this case and trigger the alarm directly... I will do some experiments when I find some time...
I was thinking about it again... In your latest screenshot you click the Start button and your idea is to set an immediate alarm to open the app above the lockscreen... this does not make much sense like this, because your app already is running, isn't it?
Please describe your use case more in detail... are you trying to open the app above the lockscreen from the background using itoo together with the alarmmanager extension?