Querying for SMS sent via Project Fi - android

When an SMS is sent/received on a Project Fi Android phone using Hangouts/Messenger how is it stored?
When querying for messages using Android's sms or mms ContentProviders I'm only getting sms messages sent/received when the phone wasn't part of Project Fi.
Any way to query for those messages? Are those messages even stored on the same DB?
P.S.
I'm aware that only Hangouts/Messenger are supported for sending/receiving:
On third-party apps
If you're using any app other than Messenger or Hangouts to send and
receive messages, download the most recent version of Messenger and
make it your default messaging app for best results.
I want to be able only to query for those messages sent via one of those apps.

Related

send and receive message in messenger software like WhatsApp

In messaging applications like WhatsApp or Telegram, how to send and receive messages.
Does the software check the server every few seconds once?
I've made a program for sending and receiving messages that the software checks the server every few seconds and if that message is new, it will display that message to the user.
Is my way of working correct?
You can use Firebase real-time database.
Reference: https://code.tutsplus.com/tutorials/how-to-create-an-android-chat-app-using-firebase--cms-27397
There is also a possibility of using Firebase messaging directly but it is more involved.
For your question about how do whatsApp and other messaging apps work, they basically rely on sending notifications to the device when a message is received.
https://medium.com/#cdmunoz/working-easily-with-fcm-push-notifications-in-android-e1804c80f74
User authentication, identification and determining which users to target for a notification are other constraints. Libraries such as those provided by Firebase can manage a lot of these details for you.

Android client to client messaging without my own server for GCM

I am doing a prototype that involves messaging between clients.
What I want to do - from MyApp on device1, able to send message to MyApp on device2. Device2 should receive this and show a notification.
I don't have my own application server to push notifications from GCM to GCM clients.Is this possible ? How to do it ?
What I investigated - PubNub, which has a trial license that seems to answer my need to send messages on a channel without needing a server.
This discussion at SO didn't help much.
sending client to client messages without server interaction
Can anyone suggest better ways ?
You basically have to use a server in one way or another. I think Firebase would be perfect for your purposes. It has an Android plugin you can use that will basically alert your app when something changes in the database. Here is the documentation for that feature. Take a look at this example for implementation. Before you can use the plugin, you need to create an account and whatnot (basic one is free). Here are the instructions.
PubNub Realtime Messaging and Push Notifications
(server not required)
With PubNub, you do not need your own server to do the realtime messaging or the mobile push notifications. You likely have your own server for your database (MySQL or similar, traditional RDBMS, a No SQL DB like MongoDB, or a realtime DB sync, like Firebase) to authenticate users and such.
For realtime DB or non-DB type change notifications and signaling (any type of realtime messaging), PubNub makes is super simple to receive messages in realtime with a mobile push notification fallback in one publish action. So the GCM message will be sent along with the realtime message. If the app is actively running, you get it in realtime (< 1/4 on average - typically faster) and the GCM message will be received if the app is not active (background or not started at all).
And PubNub's free plan is not a trial (anymore). It is free (including all add-ons) for as long as you stay within the free plan limits.
See the PubNub Android docs for more details and contact PubNub support if you have any further questions with getting started or getting answers to any questions you have as you progress with your app implementation.
Another possibility is to use the SMS.
Android Send and Recieve Messages
"Send Binary (Data) SMS
We can send binary messages (as opposed to text based messages that we covered earlier) to specific application ports using sendDataMessage(). According to this Stack Exchange thread data sms is one which is sent over 2G/3G as well as GSM. I’ve tested it with mobile data turned off and it works fine charging me the same amount, so not very sure on whether it uses 2G/3G or not, but generally the term data is used in telephony when it’s related to network (tcp/ip). Anyway, SMS’s are generally sent to a specific port on the device (which is probably port 0 [zero]). But using sendDataMessage() we can send SMS’s to some other random port on which our app can listen for incoming SMSs and do something with that. In this case the default messaging app will not store the SMSs in their inbox for both the sender as well as the receiver.
"

Android 4.4+ How do apps like MightyText and AirDroid send SMS?

Both of these applications allow you to send SMS on your desktop/through a web browser as if it's coming from your phone (it really is coming from your phone). My question is:
How do they automatically send SMS through the Default SMS App (Messenger) without any user interaction (in the background/discretely) on Android 4.4?
Any app that has SEND_SMS permission can send the message using SmsManager.
The default SMS app is responsible for writing the sent messages to the sms provider.
Apps like mightytext, mobitexter which allow to send sms from web sends the message using SmsManager and in 4.4+ the default SMS app takes care of writing the sent messages to the sms provider.
For more details you can read http://android-developers.blogspot.in/2013/10/getting-your-sms-apps-ready-for-kitkat.html
PS: I work on a similar app mobitexter.net
MightyText has permission to send sms messages. So the app is not using the default sms app, but sending the messages using the Android API.
Messages send by the app are added to the default messaging SQL database on the phone. Because of that it will look like the default app has send them.

Is there a reason not to store data from messaging app in android sms databases?

I built a messaging app that allows users to send and receive sms messages along with other types of messages. Right now I am storing all of the sent and received messages in Android's default databases that hold all sms messages. (content://sms/inbox and content://sms/sent) Is there any reason why this would be a bad idea? I know I could use my own database but unless there is a reason I should I like the simplicity of using the database that already exists on the users phone.
Also will all android devices from all manufacturers have their sms databases in the same place that I will be able to access or will their be issues across different devices and manufacturers?
It is perfectly ok to use existing databases. This is the way many existing messaging apps work.
I can't answer for all users, but I imagine a significant number of them (myself included) would object to having non-SMS messages stored in the same database as SMS messages.
If I used your app, and then opened up the stock SMS app and saw non-SMS messages there, I'd go on a rampage.

Making Android Messaging app recognize messages sent from other app

When I send an SMS message in my Android application, is it possible to make the built-in Messaging app recognize that the message was sent and show it in the appropriate thread?
Currently when my app sends a message, there is no record of it being sent. I would like the message to show up like any other message sent from the phone. I'm hoping for something easier than manually adding the message to the sms database.
You can use the following code to store to the same folder as Messaging app.
ContentValues values = new ContentValues();
values.put("address", phoneNumber);
values.put("body", smsText);
// Note: This uses an Android internal API to save to Sent-folder
context.getContentResolver().insert(Uri.parse("content://sms/sent"), values);
This uses some internal APIs and may brake in future releases / not work on some phones, but as I mentioned in my comment some apps with millions of installs are doing something similar.
is it possible to make the built-in Messaging app recognize that the message was sent and show it in the appropriate thread?
There is no "built-in Messaging app" in Android. While each device with SMS capability has an SMS client, only some use the Messaging app that is part of the Android open source project. Others use their own.
Regardless, they only show messages they sent. The notion of "sent" messages and "the appropriate thread" is a client concept, not an operating system concept.
I'm hoping for something easier than manually adding the message to the sms database.
There is no "sms database" in Android. You are probably thinking of the content provider from the Messaging app. Again, the Messaging app is an app, not an operating system feature, and that app is not on every device. The Messaging app's "sms database" is not documented or supported -- on the contrary, Google specifically states that it is not for your use.

Categories

Resources