Essentials: PhoneDialer API's

Created on 25 Feb 2018  路  6Comments  路  Source: xamarin/Essentials

A simple API to open the default dialer, preloaded with a number and name.

static class PhoneDialer {
    static bool IsSupported { get; }
    // should throw a NotSupportedOnDeviceException if the device is not capable.
    static void Open(string number);
}

For the discussion around exceptions, see #19

Most helpful comment

I think eventually we may add this sort of thing in, but let's stick to things that work everywhere for the most part for now.

All 6 comments

As for me it can be simplified:

static class PhoneDialer
{
    static bool CanOpenDialer { get; }
    static void OpenDialer(string number);
    static void OpenDialer(string number, string name);
}

Just a few moments to clarify:

  • there is no need in Task *Async(), because it seems to be sync everywhere;
  • via this API all we want to do is to open phone dialer, so why do we have Call method? OpenDial() seems more natural;
  • should we take into account CountryIso, or let the user decide?
  • two methods OpenDial(...) can be simplified to a single OpenDial(string number, string name = null) or we can left these two methods?

Thanks for your feedback. I am really agreeing with you here.

With regards to the methods, we would like to avoid the default parameters as this may make it harder to change in future.

I am thinking that in the Platform we can have "capabilities" instead of each API having a "can do this"

static class Capabilities

static class Capabilities
{
  bool HasTelephony { get; }
}
static class PhoneDialer
{
    static void Open(string number);
}

use:

if(Capabilities.HasTelephony)
   PhoneDialier.Open("+15555555555");

I don't know if we need a name option as I don't think that is handled gracefully.

We should also avoid duplicating words if it is in the class name.

I think we should move this (Capabilities) discussion to #17 - I have a longer comment there

I removed the name parameter as it is just supported on UWP right now.

However, if this is a cool feature, we could probably just add it to the UWP version:

class Dialer {
#if UWP
    void Open(string number, string name);
#endif
    void Open(string number);
}

This way we get a nice feature, but do not add it to the cross-platform API where it is not supported.
Thoughts?

I think eventually we may add this sort of thing in, but let's stick to things that work everywhere for the most part for now.

Was this page helpful?
0 / 5 - 0 ratings