There will be no text file anymore
All data will be stored in your app... this could be in TinyDB or Sqlite
Taifun
There will be no text file anymore
All data will be stored in your app... this could be in TinyDB or Sqlite
Taifun
Okay, how can i pick each value to perform some action for each values individually?
I tried to split the global variable data using split-text block but not succeeded when i tested using do it feature.
I guess, this is happening because mit ai2 is adding additional double quotes in between data forcefully. Let me try again. Thankyou.
Unfortunately we do not know how your data looks like
The best I can advice based on that little information you provided is to learn how to work with lists
Taifun
I modified the tasker code again to make the mit ai2 portion of the project much easier.
EVENT: FILE MODIFIED =>FILE: Download/177.txt;EVENT:Modify
CODE BELOW:
Task: TempPrecise
Settings: Run Both Together
A1: AutoNotification Query [
Configuration: Persistency Type: Both
Notification Apps: FairEmail
Get All Fields : true
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A2: Write File [
File: Download/CSV File Viewer/hi.txt
Text: %antextbig()
Add Newline: On ]
A3: AutoNotification Cancel [
Configuration: Id: %anid
Notification Apps: FairEmail
Package Name: %anpackage (case ins)
Timeout (Seconds): 20
Structure Output (JSON, etc): On ]
A4: Read File [
File: Download/CSV File Viewer/hi.txt
To Var: %textfile
Structure Output (JSON, etc): On ]
A5: Variable Search Replace [
Variable: %textfile
Search: \bkey\w*\b
Store Matches In Array: %textkeys ]
A6: Variable Set [
Name: %GlobalTextKeys
To: %textkeys
Structure Output (JSON, etc): On ]
A7: Write File [
File: Download/CSV File Viewer/antextbig an.txt
Text: %textkeys()
Add Newline: On ]
A8: Read File [
File: Download/CSV File Viewer/antextbig an.txt
To Var: %textfilewithkeys
Structure Output (JSON, etc): On ]
A9: Variable Set [
Name: %newline
To:
Structure Output (JSON, etc): On ]
A10: Variable Set [
Name: %newspace
To:
Structure Output (JSON, etc): On ]
A11: Variable Search Replace [
Variable: %textfilewithkeys
Search: ,
Replace Matches: On
Replace With: %newspace ]
A12: Variable Search Replace [
Variable: %textfilewithkeys
Search:
Replace Matches: On
Replace With: %newline ]
A13: Variable Set [
Name: %text_data
To: %textfilewithkeys
Structure Output (JSON, etc): On ]
A14: Variable Split [
Name: %text_data
Splitter: %newline ]
A15: Read File [
File: Download/CSV File Viewer/2010.csv
To Var: %csv_data
Structure Output (JSON, etc): On ]
A16: Variable Set [
Name: %to_search
To: %text_data(+/)
Structure Output (JSON, etc): On ]
A17: Stop [ ]
If [ %csv_data.Header3(#?%to_search) eq 0 ]
A18: Array Set [
Variable Array: %indexes_of_matches
Values: %csv_data.Header3(#?%to_search)
Splitter: , ]
A19: Variable Set [
Name: %wrap
To: %indexes_of_matches(#)+1
Do Maths: On
Max Rounding Digits: 3
Structure Output (JSON, etc): On ]
A20: Variable Add [
Name: %Increment
Value: 1
Wrap Around: %wrap ]
A21: Variable Set [
Name: %Increment
To: 1
Structure Output (JSON, etc): On ]
If [ %Increment ~ 0 ]
A22: Variable Set [
Name: %next
To: %indexes_of_matches(%Increment)
Structure Output (JSON, etc): On ]
A23: Flash [
Text: %csv_data.Header3(%next)
Continue Task Immediately: On
Dismiss On Click: On ]
A24: Variable Search Replace [
Variable: %csv_data
Search: \Q%csv_data.Header1(%first_match),%csv_data.Header2(%first_match),%csv_data.Header3(%first_match)\E
Replace Matches: On
Replace With: $0,find ]
A25: Write File [
File: Download/177.txt
Text: %csv_data.Header3(%next)
Add Newline: On ]
And, the Blocks are:
Explanation:
The tasker code will run only if the text file is modified. Mit ai2 app will read the data/onesignalID/keyword from the text file and delete it. So, since the text file got modified, the tasker code will run and update the textfile with another onesignalID/keyword. The process continues.
Anyhow, I have to crosscheck if there is any possibility for errors in different situations. I may have to use clock in the blocks.
May I know the way to correct the word json?
And, can I search the word in notifications using regular expression like this \bkey\w*\b , so, if there is any word with prefix key in notification, then some task will be done?
The event offers the attributes oackageName, title and text... there is no such attribute json available
Use a regex extension...you can find them after doing a search in the extensions directory App Inventor Extensions | Pura Vida Apps
See again Notification Listener (powered by itoox-wrapper) and Itoo
Taifun
Okay, I shall correct that Json part as you explained.
I have to do one more thing in the above blocks I shared, ie, 'If no notification from Ecwid is recieved for more than 60 seconds, then run the whole blocks only once' .
If Ecwid notifications are coming within 60 seconds or at any time, then the whole blocks will run automatically with the help of Notification Listener. But, the whole blocks will not run if there is no new ecwid notification. So only, I decided to run the code only once after waiting for 60 seconds. By, doing this, the app will get the onesignal ID (that was stuck in a text file) from the text file that was stored earlier by Tasker after processing/analyzing the previous Ecwid notification.
Now both Mit ai2 app and Tasker are interconnected. If one app run then the other app will also run.
So, how can I set this 60 sec time limit in this mit ai2 app?
Use a clock component, set the timer interval to 60000 and do what you want to do in the Timer event
Taifun
Clock has to function only if there is no notif8cation from ecwid for over 60 seconds. So, do I have to include TinyDB to know if there is abaence of ecwid notification for more than 60 seconds?
How can I know the time of new Notificatiin Recieved? If I use counter for each new notif8cation, then how can I deny the counter if new notifications recieved within 60 seconds OR how xan I accept the counter value only if no new notifications recieved within 60 seconds.
How can I reset the counter value if new notifification recieved within 60 seconds so the counter will start once again?
This is like a countdown from 60 to 0
search this community for countdown examles
If there is a new notification, reset the countdown to 60
if the countdown is at 0, then do what you want to do
Taifun
Do I have to give any permission to the app for accessing Notifications?
No
Taifun
In Android 11, it is directing me to another page 'Notification Access'. Since I am trying Companion, my app is not in the list also.
Do it feature is working.
My Android phone not allowed me to install the app as well, then I changed the play settings to install it.
from the Q&A section App Inventor Extensions: Notification Listener | Pura Vida Apps
Q1 : Is it possible for make the extension working in debug mode? I have problems in developing my app, because I have to compile the code each time to get a good code.
A : Unfortunately it is not possible to test extensions, which use a service like the notification listener extension in the companion app. This is a technical restriction of the companion app.
But for easier developing of your app, just modify the example project and add a button to export the TinyDB into a file. You could use the Get all TinyDB Extension by Juan Antonio to backup TinyDB as Text or JSON format. Let the example project run for a while until you collected several notifications and then export TinyDB. Then in your app you like to develop import the stored TinyDB and work with the previously stored notifications.
Taifun
Android 11 phone is not allowing to install the app. It is saying something like the app may access personal infromation. To install the app then I changed the play security settings.
When I tested the above block in companion app using do it feature, the global variable produced the expected result. But, when i tried the app after installing it, it is not recognizing the new notifications & running the blocks.
The data in text file is not getting updated. It is getting updated on companian app when I checked using Do it Feature. but not working after installation.
Why do you need 2 MFile components?
And what is the purpose to ask, if the file is empty? And if it is not empty, you do exactly the sane and store an empty text in the file... does not make much sense for me...
Your example will only work if your app is up and running and no other ptocess edited the file
We already talked about that...
The extension will not work in the companion app
Taifun