Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Feedback on the SMS API
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jonas Sicking  
View profile  
 More options Nov 12 2012, 7:19 pm
Newsgroups: mozilla.dev.webapi
From: Jonas Sicking <jo...@sicking.cc>
Date: Mon, 12 Nov 2012 16:18:31 -0800
Local: Mon, Nov 12 2012 7:18 pm
Subject: Re: Feedback on the SMS API

On Fri, Nov 9, 2012 at 1:58 AM, David Bruant <bruan...@gmail.com> wrote:
> Le 09/11/2012 09:03, Jonas Sicking a écrit :

>> On Tue, Nov 6, 2012 at 4:32 AM, David Bruant <bruan...@gmail.com> wrote:

>>> # The SmsRequest object smells like a promise. It does very very badly.
>>> What
>>> about actually making it a promise so it can share a uniform interface
>>> with
>>> other async features and things like Q.all (creates a promise that is
>>> fulfilled when all promises passed as arguments are fulfilled) be built
>>> on
>>> top of these promises?

>> I'd love to have a standardized promise API which we could use. If
>> someone gets something standardized then I'd love to switch to using
>> it.

>> https://twitter.com/SickingJ/status/202152629743255552

> :-D

I'm quite serious. The web needs a standardized promise.

>>> # The send method takes a string as first argument. String rarely are a
>>> good
>>> thing to represent objects. Especially phone numbers.
>>> An anecdote, In France, cell phone numbers used to start with "06". We
>>> ran
>>> out, so it's been decided that cell phone numbers would also start with
>>> "07". A friend of mine shared with me that it took 6 months of
>>> development
>>> to FranceTelecom (historical and major Telco operator) to prepare to this
>>> change, mostly because they used strings to represent phone numbers.
>>> Especially with cell phones shipping all across the globe, I really think
>>> there is value in having an object representation of phone numbers, very
>>> much like we do (sort of) with URLs.

>> So far no-one has come up with a standard for a parsed phone number.
>> We're still fighting over what a parsed URL looks like and phone
>> numbers are dramatically more complicated since the rules are
>> different in different countries.

>> If you figure out a way to solve this, I'm all ears.

>>> # I hardly see the need of the second send method that accepts an array.
>>> For
>>> a developer, it takes one longer line to achieve the same thing:
>>>      var requests = myNumbers.map(function(num){ return send(num,
>>> message)
>>> });

>>> It would probably simplify the implementation of send on your side.

>> I tend to agree.

> Jose's made a good point though, that when you send one message to several
> people, it's not the same than sending two messages with the same content to
> two different people.

Actually, in SMS it is. SMS doesn't have the ability to send the same
message to multiple people. When you are entering multiple recipients
in an SMS app it actually turns around and sends a set of separate
messages. This is why this function returns an array of SMSRequests,
since the messages will be sent independently and thus can fail
independently.

MMS however allows sending a single message to multiple people. But
the API doesn't support MMS yet. And I don't think the API should get
into the business of trying to guess when to send a message as an SMS
and when to send it as an MMS.

>>> # "Should use opaque objects as message-identifiers rather than longs?"
>>> => Yes, and the SmsMessage instance itself is this object.
>>>  From the object capability perspective, it would be better to be able to
>>> delete only messages you have access to.
>>> Actually, I would rather prefer SmsMessage.prototype.delete than
>>> SmsManager.delete, this way, it's clear you can only delete messages you
>>> have access to.

>> This would make it impossible to store a message identifier in
>> IndexedDB, which can be quite useful when building more complex UIs.

> I agree message ids should be kept in the SmsMessage API and as a retrieval
> mechanism in SmsManager.get(id). But that's where it should stop in my
> opinion. Every operation that affects only a given message (delete,
> markAsRead) should be a method in the SmsMessage interface applied to the
> message instance, not in the SmsManager interface.

Being able to store identifiers in local databases is a requirement in
my opinion. Otherwise it gets very hard to cache any data locally in
the app and cross-reference to the SMS database.

>>> # getMessages and SmsFilter
>>> A more generic way would be to accept a function as first argument. This
>>> function is passed a SmsMessage and returns true or false depending on
>>> whether we want to keep the message or not akin to
>>> Array.prototype.filter.
>>> It would be interesting to provide some convenience with SmsFilters:

>>>       var filter = new SmsFilter({delivery: "received"});
>>>       SmsManager.getMessages(filter).then(function(receivedSms){
>>>           // ...
>>>       })
>>> (the "then" is assuming SmsRequest become promises)

>>> Basically, SmsFilter generates a function which [[Call]] does the right
>>> thing based on the passed arguments, but it's a convenience rather than a
>>> compulsory thing.

>> The performance of that would be really bad since we couldn't use an
>> index to iterate just the messages that are requested.

> How bad would it really be? What is the performance benefit (in time, not
> percentage) of having indexes? (If people have thousands of Sms, I hardly
> believe that an index makes a noticeable difference)
> Also, I agree that a user-generated function can't have the semantics to
> leverage indexes, but system generated functions using the SmsFilter
> constructor as I suggested could.
> What I've suggested allows to leverage anything that the current API offers.
> I'm just offering the freedom to do arbitrary filters (which the current API
> doesn't allow).

The difference between using an index which only contains the 10
messages that you have exchanged with a specific person, vs. using a
filter which is required to scan the 10000 messages that you have in
the full database is about three orders of magnitude :)

So yes, it makes a big difference.

We recently had to rewrite a part of the SMS app in order to avoid a
full database scan since it caused the app to take several seconds to
start. With the rewrite the database scan is basically instantaneous.

> Also, I forgot, but in the getMessages method, both arguments should be
> optional in my opinion. Reverse defaulting to false and filter to...
> undefined? and no filter would return a promise (hopefully soon) to all
> messages.

I believe that's already the case in the implementation.

/ Jonas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.