How to make my SMS App is highest Priority to receive Broadcast Receiver - android-broadcast

At First, I am sorry for my English is not good enough !
My problem is i am writting a Block SMS Application and i want to receive sms with my app and then i abort broadcast to make default sms app can't receive SMS, so i set my app have a highest priority (1000), but my app still receive broadcast after default sms app of android.
I print all of my Android Phone SMS's broadcast received signal in order when my phone receive a SMS and i recognize that The System SMS App alway receive SMS Broadcast first and it also have Highest priority.
So how can i make my sms app could receive SMS Broadcast before Default SMS of system ?
I am really needed your help !
Thank for your reading !

As documented by Google, the maximum priority for a broadcast receiver is less than 1000, literally 999.
But you can set it to a maximum level of 2147483647. As other apps on Google Play uses higher priority (more than 999) than your Broadcast receiver, due to this your app may not receive the SMS. By this maximum level, your app will always receive the SMS first.
So this way you can get broadcast before the default messaging app.
See this answer!
Edit
I was revisiting my old answers on StackOverflow and this answer looked sketchy. The following is an excerpt from the official documentation of IntentFilter priority.
The priority that should be given to the parent component with regard to handling intents of the type described by the filter. This attribute has meaning for both activities and broadcast receivers:
It provides information about how able an activity is to respond to an intent that matches the filter, relative to other activities that could also respond to the intent. When an intent could be handled by multiple activities with different priorities, Android will consider only those with higher priority values as potential targets for the intent.
It controls the order in which broadcast receivers are executed to receive broadcast messages. Those with higher priority values are called before those with lower values. (The order applies only to synchronous messages; it's ignored for asynchronous messages.)
The official lower and upper limits are still -1000 and 1000 respectively. Broadcast receivers with higher priority can abort ordered broadcasts, hence, preventing other receivers with a lower priority from receiving them.

Related

ZeroMQ PUSH / PULL - how to know which events are pending in SEND BUFFER queue?

We have a service pair doing PUSH/PULL pattern of message communication. As mentioned in the docs, if the PULL service is down or not running, then a sender will queue up to high water mark number of events and by default a .send() after that will block.
Now, while an app is in the blocking state, the app could be killed or something else may happen, leading up to loosing those messages in the queue.
I understand PUSH/PULL is not the best method if we want that kind of reliability and should probably use some of the other method listed at: https://zguide.zeromq.org/docs/chapter4/ but is there a way in PUSH/PULL method to get event call back on the events still on queue on say app exit/periodic callbacks/signals?
I also understand, that I could use NOBLOCK or ZMQ_IMMEDIATE or ZMQ_SNDTIMEO in such situation and catch the error and use application level recovery (similar to DLQ pattern) but I was looking into things available from the ZeroMQ library.
Q : "... how to know which events are pending in SEND BUFFER queue ?"
A :Well,having used ZeroMQ since v2.1, v3.x, till v4.x in 2022-Q1, there has never been a way, how a user-level code may interact with ZeroMQ internal queues and/or state(s) as there was no such method in c-API to do so.
Q : "... is there a way in PUSH/PULL method to get event call back on the events still on queue on say app exit/periodic callbacks/signals?"
A :Well, let's solve this by using a concurrently operated signalling-socket, for receiving POSACK-messages from "live"-clients, i.e. those, that can and do receive messages - thus being able to back-throttle messages for those, that did not respond in reasonable TAT. Using a mix of several, properly selected Scalable Formal Communications Patterns archetypes to work in cooperation, helps solve this "soft"-signalling control. Without an ambition to solve all details, a set of one-PUB.bind() / many-SUB.connect()-sockets for selectively directed payload-transport with subscription-based controls and one-PULL.bind() / many-PUSH.connect()-s for "soft"-control signalling of still-alive-heartbeats, traffic back-throttling and similar services

iBeacon: When to send beacon event to a server

Am working on iBeacon app where I monitor and range beacon however, when the app start ranging for a beacon in region I get endless list of beacon range status as long as the user in the beacon range.
My question is when to send the server the beacon proximity!
And if someone could explain the optimal way to queue and send list of beacons events to web server! it will be much appreciated.
The optimal way to send beacon proximity events to the server all depends on your business use case. Here are a few common options:
Send an event whenever a new beacon identifier is first detected, along with the proximity at that time.
Send an event periodically (say every 10 minutes) with a full list of beacons seen during that period along with their minimum/maximum proximities over that period.
Send an event whenever the proximity crosses a threshold (e.g. send an event only when a unique beacon identifier first becomes in near or immediate proximity).
Implementing the above on iOS often involves tracking the detections in a Dictionary, and then triggering the server call at the appropriate logical time from the didRangeBeacons:inRegion callback based on what has been tracked so far in this dictionary. Using logic to implement 1, 2 or 3 above will ensure that the number of server calls will be limited.

If there are two listeners / subscribers which one replies to TibRvdTransport.sendRequest(message,timeout)

if I am sending a message onto a multicast topic using:
TibrvMsg replyMessage = TibRvdTransport.sendRequest(message,timeout)
and there are two subscribers, which one actually sends the replyMessage, and what happens to the other replyMessage ?
I can only guess the fastest one that that answers. But I cannot see this documented anywhere.
Since your components are decoupled, they are unaware of each other. Rendezvous is pub-sub, which means that all subscribers receive all messages published to subjects that they have subscribed to. Furthermore, Rendezvous uses a peer-to-peer messaging approach vis-a-vis a centralized message forwarding approach. Therefore both components will receive the message and both components will reply.
If this is not the desired behavior, with Rendezvous you can use a distributed queue (RVDQ). With that approach a "scheduler" assigns work to workers, ensuring that messages get processed only once.

Using Twilio SMS API, can I specify multiple destination phones in one post?

Twilio limits long code SMS to 1/sec. To improve my throughput, I split my batch into 5 phone numbers. I've found each HTTP POST to the Twilio API takes about 0.5 seconds.
One would think using 5 twilio phone numbers to send a message to 1000 cell phones would take 200 seconds, but it will take 500 seconds just to POST the requests. So two phone numbers will double my throughput, but more would not make a difference.
Am I missing something? I was thinking it would be nice if the API would take a list of phone numbers for the "To" parameter. I don't want to pay for a short code, but even if I do it seems the maximum throughput is 2/sec unless you resort to the complexity of having multiple threads feeding Twilio.
I've noticed TwiML during a call let's you include multiple sms nodes when constructing a response so it seems like there should be a way to do the same for outbound SMS.
Twilio Evangelist here. At the moment, we require that you submit each outgoing SMS message as its own API request.
The current rate limit on a longcode is 1 message per second. If more messages per second are sent, Twilio queues them up and sends them out at a rate of 1 per second.
A potential workaround is to make async requests across multiple phone numbers. This can be accomplished with the twilio node.js module or an evented framework such as EventMachine for Ruby or a similar toolset for your language of choice.
Hope this helps!
Here's a more modern answer. Twilio now supports Messaging Services. It basically lets you create a service that can group multiple outbound phone numbers together. So, when you fire off requests for a text to be sent, it can use ALL the numbers in the message group to perform the sending. This effectively overcomes the 1 text per second limit.
Messaging services also comes with Copilot. It adds several features such as "sticky sender". This ensures the same end user always gets texts from the same number in the pool instead of getting a text from different numbers.
If you are using the trial account, even looping with a 5s timeout between each item in the array did not work for me. And that was for just two numbers. Once I upgraded the account the code worked immediately without needing a timeout.
You know it's the trial account if the SMS you receive (when sending to only one number) says "Sent from your Twilio trial account - ".

How do some SMS messages transmit the senders name?

I have noticed that certain SMS messages that I receive from companies come with a 'sender name'. eg. Just today I received an SMS from a number I have never used before (not im my contacts), however the senders name showed up as 'Adobe'. I get this from other companies too. eg Facebook, Google & Banking.
Is it similar to how a email server works? (you tell the server who you 'are' before you send the message) Is this the case with a carrier's cell tower?
I guess I'm wondering what the service is called and how it works? (ie. can you send 'header info' with SMS messages or is the cell tower just spoofing the message's 'sender number' and replacing it with characters?)
(hopefully this is the right place to ask this question...)
The MAP protocol (the one used for sending SMS messages among others) allow specifying either a phone number or an alphanumeric number as the sender.
AFAIK this cannot be set from your phone where the sender number will be always your public phone number but SMS Centers can allow sending such messages on other interfaces like the ones used by banks and the companies mentioned by you (usually using the SMPP or UCP protocoll).
Please note that some Telcos do not allow this kind of sender address in messages originated elsewhere but sent to their customers (or they don't allow it for everybody). They use SMS spam filters/firewalls called Home Routers for this.
Mobile communication in GSM, UMTS and LTE is governed by 3GPP.
The TP-OA field in SMS-DELIVER TPDU in an incoming SMS typically contains the number of a sender.
The network fills the TP-OA field with usually an MSISDN.
Please see 3GPP TS 23.040 Figure C.10.
But in case of a company name, TP-OA can be made alphanumeric using the Type of Number Information Element as 7-bit default alphabet
I suggest you to read 3GPP TS 24.011 and 23.040 to get an idea of how SMSes work.
However, I must point out that since a sender does not send TP-OA, it can't be easily spoofed.

Resources