New Notification to status bar extension


#1

Update - Now the notifications show info icon in status bar and your app icon in notification field. Be advised that in Companion shows Companion icon

Hi. I’ve made this extension according to my need to have notifications sent by my app itself, without needing an external operator or service.
So here it is.
You can send notifications with app running in foreground or background , you can choose three styles of notifications (a simple row, a long multi-rows text, multiple messages queued in a single notification).
Every notification has its own id. , so a new one pushed do not cancel a previous one.
The notification can be delayed for some seconds or set at a fixed future time, in format hour and minute, making it easily repeatable.
The blocks are quite self-explanatory about their functions. I hope it would be useful.
com.tiziano1960.Notifications.aix (18.0 KB)

How it works:
SetStyle - here you can set the desired style of notification as follow (need a string with one of values below)

  • 1 - simple one row notification (string is truncated if it exceeds one row length limitation);only first item of a list of strings is considered

  • 2 - multiple rows notification (longest string are fully shown ); only first item of a list of strings is considered

  • 3 - multiple messages notification, a list of messages is queued and shown in a single notification

SetDelay - here you can set delay for notifications (need a list of strings with two items)

  • if you want to set an absolute delay it must be in seconds, indicated in the first item, while the second item has a zero in.
    Example of delay of 150 seconds (“150”,“0”)

  • if you want to set a relative delay it must indicate the hour and minute at which the notification has to be sent. In this case the first list item has a zero in and second the time desired in format HH:MM
    Example of execution at 16:45 (“0”,“16:45”)

Notify
title parameter needs a string with notification title
yourMsgList parameter needs a string list with your messages to show (with style 1 and 2 only the first message is relevant)
startValueText param. needs a string null or with a text to pass to Screen1 of your activity when it restarts
isDelayed param. needs true/false values if you desire or not to delay your notifications (if true the delay is that one set by SetDelay property)

SendBackThisApp
simply hides the app from view

example of blocks assembling


Receive a notification in the mobile status like WhatsApp
#2

ciao tiziano, mi sembra una estensione eccezionale (tralasciando i fagioli che non mi piacciono)

le notifiche avvengono in background? ma app inventor può girare in background?


#3

Stupefacente Tiziano, non vedo l"ora di provarla domani.Sei riuscito ad implementare una funzionalità che si cercava da anni.Perché’ non posti un file AIA come esempio,così che sia comprensibile a tutti.Di nuovo complimenti.


#4

Works with app in hidden state,not in background


#5

The activity is really in background (it is not a service though ), being its state onPause () or even onStop (), when it is no more on foreground and has not reached the onDestroy (); about onStop () state I’m not sure and I would look into the subject deeper.


#6

Nice extension. However, it would be very useful if you showed us some screenshots with the notification in action. : )


#7

@Tiziano1960
Nice work… I have started testing this one now, thanks for the contribution.
There is also a similar Notification however you added the 3 different styles…

Please explain a little bit better the integers that we need to put for getting multiple messages…
This is not clear enough (not for me at list).
Also you have descriptions in blocks, but consider to place a more detailed documentation (especially if you intend to further expand this extension)

BTW what about adding an option as @Taifun did to… “return whether click onto notification should be ignored”, it might be useful for some…


#8

Arghh… I made a little mistake on style 3, so I attach now the correct aix file in first post. Please excuse me.


#9

As I say above, there was a little mistake, now fixed on style 3 (Multiple Message). Try it now, there’s no special differences related to simple/ long-text or multi message styles, the list should contain a min. of 1 message and a max of 5 messages.
In any case a style 1 or 2 will grab only first item in list ( in style 1 it is cut to make it fill just one row), a style 3 will queue any message in list,with a limit of 5, in a single notification. Speaking of further doc. , you’re right , I should do something about it, and I will do as soon as further steps in this ext. will be completed.


#10

ciao tiziano, puoi fare un video per far vedere come funziona?

inoltre, come fa a funzionare in background? app inventor mica può funzionare in background?


#11

Documentation added (first post)


#12

How about adding a feature that when notification is clicked it takes you to a specific screen as detailed in this thread.

In Case, your extension could do this, your extension would simply replace the ONESIGNAL extension from thunkable.


#13

App inventor può utilizzare i componenti già esistenti sul server dedicato MIT per creare servizi funzionanti in background, tuttavia questa estensione non funziona come un servizio, crea invece un Bundle che mantiene informazioni utilizzate in seguito, quando l’app è in stato onPause/onStop per inviare notifiche in grado di riportarla a onResume.


#14

did you mean like this?


#15

Is this working for anyone? With these settings

my application crashes when I call your procedure


#16

Have you installed the updated extension, deleting older one? If yes are you using other extensions in your app and which is your android API version.? And does it happen only with the style set to 3 ? Thanks for your interest,!


#17

Hi, I try this extension & Taifun Push Notification Extension on AI2 but for both extensions, notifications only work if my application is visible on the screen of my phone.
If, on my phone, I click on home button to return to my home screen (I do not close application), no notification. I selected my app in task manager to bring it back visible and notification works again.

Is there any reason for notifications do no work when my app is not visible on the screen of my phone?

thanks for help


#18

#19

I checked it on two devices now. App crashed on Android 2.3 and Android 6.0. Sadly none of the styles work. Extensions are your updated version and Taifun’s notification extension


#20

to find out more about the Runtime Error, you can use Logcat

I normally use Eclipse and Logcat there, but if you have installed the App Inventor Software (see also http://appinventor.mit.edu/explore/ai2/setup-emulator.html), you already have everything you need to use logcat…

How to use Logcat

  1. connect your device using USB with your computer

  2. in File Manager go to the App Inventor directory, which is C:\Program Files\App Inventor or similar

  3. press Shift and right mouse click the subdirectory commands-for-Appinventor to get the context menu

  4. select “open command window here” and you will get a command window of that subdirectory

  5. enter *adb logcat :E and the logcat will start running and log all errors

  6. start your app to elicit the error

  7. copy the log (see below)

To copy your log, right click, click “select all” and enter to copy the complete log into the clipboard, then open Notepad and paste it using ctrl-v.

Taifun


Problem with opening new screen with start value useing list picker
Bad Apps, Usless Apps