Open J4YF7O opened 4 years ago
Hi,
The plugin does not support reading of other folders as of now, as IMHO, it is not a very common use case. My primary goal was to keep the plugin as simple as possible, and hence read only inbox.
Thank you for your answer, but why don't you look for the messages in content://sms/ rather than only in Inbox? I probably don't know enough about native Android.
Hi, As I mentioned, it was my assumption that it was the most common use case. However, it won't be much difficult to modify the plugin to look whatever folders you need like content://sms/sent
.To read all messages, you would need to use some thing like content://sms/all
I just tried with content://sms/
, but it was not possible to identify the status of the message: "sent / received".
So I added a "type" attribute to the SMS class, which when creating the object takes the value of "type" in the cursor, which allows us to know a little more about the message.
// Change in SMS.java
// Line 12 (attributs declaration)
public int type;
// Line 20 (constructor)
this.type = cursor.getInt(cursor.getColumnIndexOrThrow("type"));
// Line 58 (writeJSON)
sms.put("type", this.type);
For my use case, I really need all the messages, and this may be enough. Would you like me to collaborate and extend the functionality of your library creating a pull request, or would you prefer me to fork it?
I would be glad to accept a PR with the functionality. I would expose a new action on the js and java APIs that would accept the sms folder type string as a parameter, something likefetchSmsByFolderType(action, foldertype, since, searchtexts, senderids, permissions)
, rather than modifying/breaking the existing APIs. Please let me know if you will be able to complete the same, or need any assistance.
ref Folder types
Hey,
Sorry I've had a lot of work in the meantime, and I've been able to move forward with my fix described above.
So, Today I fork the project, and do some update.
I'll explain my approach, I'll let you judge if it's the right one or not...
Only Rajeevs can judge me 😄
Reminder :
- The result of the following js methods shall not be altered :
getAllSMS, and filter*
fetchSms()
signature and add the foldertype (string)
parameter, which is set to '' by default. fetchSmsInbox()
function, which calls the fetchSms()
function with folderType set to inbox. getAllSMS, and filter*
no longer call the fetchSms() function, but fetchSmsInbox().getSmsFromFolder(folderType, since)
, which allows to receive sms from the folder passed in parameter. I am a typescript user, so I took the liberty of adding an index.d.ts file for the type definition.
Look at my last message.
folderType
param for fetchSMS
method. With this value you can concatenate the sms address. (message)execute
method : de la méthode "execute" to include support for the "folderType" parameter. I allowed myself to redefine the code structure a little bit.
PS : Your Folder type reference is bad (or not working on my Android 10) : There are no content://sms/**all**
To get all sms you have to call the empty folder type content://sms/
.
Hello,
First of all, thank's for this very useful lib. I use the library in order to read all the sms received AND sent by the user. Unfortunately, using
getAllSMS()
I only get the sms I received, but never the sms sent.Is this normal comportment for the plugin ?
J4YF7O