How do I replace Messages app on Wear OS? - android

I want to create an app for Wear OS to replace the default Messages app for handling SMS/MMS messages. To start with, my app will get messages from the phone, relying on the phone to communicate with the cellular carrier. What does my replacement app need to do to send and receive SMS/MMS messages from the phone?
Can my app communicate with the default Google messaging app on the phone (so I don't have to write a phone app too)? Is that protocol/API documented somewhere?
Does my app need to register with the watch to become the default message handler and disable the default app? If so, how do I do that?

Related

How does SMS work (with Android devices)?

We are working on a app based on Google's Rich Messaging Platform (RCS) and I'd like to ask some specific questions pertaining to how SMS is delivered into Android devices.
Questions for the matter of understanding:
Are SMS messages delivered into the Android OS or the messaging app?
Are SMS messages being pushed (ie. Push Notifications) into the Android OS or messaging app? If not, is it pulled - and how?
Do MMS work the same way as SMS, in terms of how messages are delivered?
Important Question:
If we are developing an RCS app to replace SMS. Is it possible to deal with receiving SMS directly? That is, interaction with SMS would completely bypass the Android OS and/or another (default) messaging app.
EDIT - added the following questions:
This post says we can listen to incoming SMS/MMS messages. So, here's a question:
Can our app be the only sole app to listen for SMS/MMS messages?
If the answer to the above question is no, then (after the user reads the message on our app), can our app send a message to the other SMS messaging app(s) to remove the batch count and set the message to read?
If our app is NOT using Direct Boot, will SMS/MMS be lost since they cannot be delivered, whether or not our app is the sole SMS/MMS app?
And, this question for the matter of understanding:
From what I understand now is the SMS/MMS are part of the telephony system, while RCS is NOT. Could you confirm my understanding is correct?
Thanks!
To the best of my knowledge, this is how the SMS works on Android:
Are SMS messages delivered into the Android OS or the messaging app?
SMS messages are sent to the Android OS as they are part of the telephony/cellular system. They are definitely not pushed to any particular messaging app as the incoming message comes from the cellular provider to the device (aka the OS/firmware) directly. The messaging app a user interacts with is simply a "front" for displaying and interacting with the user to send/show messages at they are received. You can actually change the default messaging app on Android which further demonstrates that SMS is actually part of the OS.
Are SMS messages being pushed (ie. Push Notifications) into the
Android OS or messaging app? If not, is it pulled - and how?
Much like an incoming phone call, SMS messages are "pushed" to the device but not in the way you may be familiar with like Push Notifications (i.e. GCM). The concept of a Push Notification is something that exists on the IP layer; that is, it's a service that runs on the Internet. The kind of push a device receives for SMS messages is part of the telephony system. This is why, for instance, devices can still receive SMS with mobile data turned off but can't receive notifications for a Facebook message.
Do MMS work the same way as SMS, in terms of how messages are
delivered?
Yes, they work essentially in the same way as described above except they have some additional protocol for how they handle the data that is received from the cellular network to fetch things like images. The data is still transmitted on this telephony network and not over Internet (for the most part). There are implementations now of MMS that may piggyback off the Internet to fetch and load images quicker but that may be carrier specific.
If we are developing an RCS app to replace SMS. Is it possible to deal
with receiving SMS directly?
It depends what you intend to do. You won't be able to fundamentally change the SMS protocol on the telephony network as this is not within your control as an application. However, you can create an app to monitor and listen for SMS message as they are received in the OS. You can check out this post on how to do that. If you wanted to create your own RCS, you'd pretty much have to do this over the Internet. Services like WhatsApp have made clever use of combining both telephony SMS and standard Internet messaging to create a seemingly seamless experience. Without further context on what you're trying to build, I won't be able to provide more help.
In the end, you should just think of native SMS as being part of the phone. For further readings on how SMS works, I suggest the SMS Wikipedia page. I hope I was able to answer some of your questions!

Android Auto initiate SMS via voice

Is it possible to create/send SMS using voice commands in Android Auto? I'm not seeing anything about it in the docs at https://developer.android.com/training/auto/messaging/index.html
I have an HTC 10 and when the stock HTC "Messages" app is set as the default, I can tap the mic and say something like "Text Alice" or "Send a message to Bob" and it will then prompt me for the message, listen, and then send it. Similarly, if I set the Android Messages app (from Google) as my default SMS application, it works fine.
Lately I have been using Signal as my default messaging app. I cannot initiate a message via Signal. If I'm using Android Auto and I say "Text Bob" it will send an SMS, but it does NOT send a Signal message even though it's the default SMS app. Instead, it will send it through the HTC Messages app even though it's not the default.
Looking at their code, they have implemented the ANDROID_AUTO_HEARD and ANDROID_AUTO_REPLY intents as mentioned in the documentation. See lines 485-497 of https://github.com/WhisperSystems/Signal-Android/blob/master/AndroidManifest.xml and then the 2 Android Auto notification handlers at https://github.com/WhisperSystems/Signal-Android/tree/master/src/org/thoughtcrime/securesms/notifications
There doesn't seem to be any sort of ANDROID_AUTO_SEND intent or anything of that sort.
Is it possible to add an intent (to Signal) to make Android Auto send SMS through it instead of the other apps? I don't understand why it isn't using Signal when it's set as the default messaging app on my phone. The Android Messages app handles this properly. Is that just because Google put some special code into that app that third-party developers aren't allowed to use?

Block incoming SMS on rooted Android 4.4 and higher?

In accordance with the doc:
Note that—beginning with Android 4.4—any attempt by your app to abort
the SMS_RECEIVED_ACTION broadcast will be ignored so all apps
interested have the chance to receive it.
so, only default SMS app can do it and looks like nothing is changed with Android 5.0 (due to unknown reason, according issue is marked as Obsolete).
Is there any way to block incoming SMS for non-default SMS app if phone is rooted (this is is needed for spam-blocking app)? How to do it?
You could write a service that overrides CarrierMessagingService .
If the bind to this is successful , then the message is not delivered to the main app.
BIND_CARRIER_MESSAGING_SERVICE permission required to register as carrier messaging service requires the app to be system app. So you need to push your app to the system.
Make your app the default SMS provider. Then it can register for SMS_DELIVER_ACTION. In that receiver, you can choose to either write the SMS to the database or not. If you choose not to, the SMS is basically ignored. If you choose to, any other app can receive the SMS.
You can try the following solution:
Iterate through list of packages capable of handling SMS and disable them programmatically.
To get an API to disable an app you will have to become an MDM(Mobile Device Management) partner app.OEMs provides additional APIs to their MDM partner apps to control the device.For example samsung provides api to disable specific app.I guess they also have APIs to control permission of specific apps.
Alternatively I guess the new android Device/Profile Owner mode must have an API to disable specific apps.

Handling Push Notification scenarios on iOS and Android

I want to implement Push Notification for an App (both iOS and Android) and need clarifications on the following scenarios.
I understand how the Push Notification works in general and the limitations. I did read the docs but that just got me confused and didnt answer all my questions.
How are the following scenarios handled in iOS and Android:
When the device is turned off
When the device is not connected to 3G or Wifi networks
When the device has crashed and need restart
When the App is in foreground
When the App is in the background
When user is currently using the App
When my app is closed (not opened / launched)
When a push notification is user specific and both users share the same device and app. Example: If a husband and wife share same device and use a bank App with Push notification.
Can you send User specific notification if device is shared by multiple users?
When user has installed App on multiple devices
Can you send a notification to all devices registered by a user at once?
Do you store the device type (iOS or Android) with the registrationID in the User table or is there a way to differentiate the type of device by inspecting the token or registrationID?
Can you cancel a previously sent notification which is not read yet and send a new one?
Is it still true that Android Push Notifications does not work on Kindle Fire and will need to implement Amazon Device Messaging
Anything else that I need to think of or plan? I am aware of handling un-registering and feedback service
I would answer some of your questions, specific to android thought. Don't know about iPhone, If its of similar kind or not.
The device receives notification from Google Cloud server as and
when the notification is triggered by the server and it doesn't have
any relation with application state (Running, Closed, Background or
foreground).
If the notification is sent to a device when its not connected to
the internet ( switched off or not connected to the net) , it gets
notification only when it connects to the network. However, if the device
is crashed and restarted after the notification is received, you
won't get the notification again.
Is it user specific?
It depends on the individual servers implementation.
Do we store device type?
Yes we can.
Can we differentiate the IDs of iPhone and android?
Yes, android Device IDs are longer in length than iPhone's.
Can we cancel an already sent notification?
No, it is a one way communication channel as far as I know.
When the device is turned off:
Answer:
IOS/Android Server (Not your Server) will handled when to send the Push Notification. It checks that device is reachable or not. We can define that how many times IOS/Android Server should try to send Push Notification.
When the device is not connected to 3G or Wifi networks
Answer:
Nothing related to 2G/3G/Wi-Fi. Device should be connected to Internet via any network.
When the device has crashed and need restart
Answer:
IOS/Android Server checks that device is reachable or not.
When the App is in foreground
Answer:
Nothing related to app in foreground.
When the App is in the background
Answer:
Nothing related to app in background.
When user is currently using the App
Answer:
Nothing related to app being used currently.
When my app is closed (not opened / launched)
Answer:
Nothing related to app is closed.
When a push notification is user specific and both users share the same device and app. Example: If a husband and wife share same device and use a bank App with Push notification.
Answer:
It depends on how you have implemented on YOUR Server. You will be managing Device Id for each user. So it's upto your implementation logic to send to same device for multiple users.
Can you send User specific notification if device is shared by multiple users?
Answer:
It depends on how you have implemented on YOUR Server. You will be managing Device Id for each user. So it's upto your implementation logic.
When user has installed App on multiple devices
Answer:
It depends on how you have implemented on YOUR Server.
Can you send a notification to all devices registered by a user at once?
Answer:
Yes again as per your implementation logic.
Do you store the device type (iOS or Android) with the registrationID in the User table or is there a way to differentiate the type of device by inspecting the token or registrationID?
Answer:
Yes you need to store the device type, to identify to which Server (IOS/Android), you need to send request for Push Notification.
Can you cancel a previously sent notification which is not read yet and send a new one?
Answer:
No you cannot cancel the request.
Is it still true that Android Push Notifications does not work on Kindle Fire and will need to implement Amazon Device Messaging
Answer:
Need to google it around.
Anything else that I need to think of or plan? I am aware of handling un-registering and feedback service
Answer:
Need to google it around.

Turn off notifications of an app programatically on Android

I am developing a package manager application which shows checkboxes to turn off notifications from different applications installed on the Android device.
Since Android 4.1, users can turn off notifications of an app from application manager. Can I turn on/off notifications from an app programatically? Is there an API for doing that?
No, you cannot do that from your code. Perhaps on rooted devices you could do some magic, but that shall not really count for wider audience.
If you are App dev, you should manage that on server side, having a webservice (REST API) allowing the user to unsubscribe to the notifications.
Then implement a Settings section in your App where user can uncheck a notification box and that call this service.
Then, your server will not send the notification to this user.

Categories

Resources