Forum Cross Platform with Xamarin

USSD request in Xamarin.Crossplatform?

I am developing a simple app using Cross Platform with Xamarin and I want to dial a number like *804#.
Can anyone tell me how to do that in Cross Platform with Xamarin?

Answers

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭

    Isn't this just a phone number, which you can dial? If so you should be able to do this (from memory) with:

    Device.OpenUri(new Uri("tel:*804#"));

  • jocodesjocodes Member ✭✭

    Thanks but this just opens the dialer with the number (*804) ignoring the # . What i need is to make the call automatically. Is that possible? Also think of why the # sign is ignored.

  • ColeXColeX Member, Xamarin Team Xamurai

    Try Xamarin.Plugins/Messaging.

    // Make Phone Call
    var phoneDialer = CrossMessaging.Current.PhoneDialer;
    if (phoneDialer.CanMakePhoneCall)
        phoneDialer.MakePhoneCall("+27219333000");
    
  • jocodesjocodes Member ✭✭
    edited December 2018

    ColeX

    It doesn't work...
    Why Xamarin does't have built in implementation for this?

  • It has, try PhoneDialer class (Xamarin.Essentials), USSD can be treated as a call, remember however that number must be url-encoded e.g.

    PhoneDialer.Open(HttpUtility.UrlEncode("*804#"));

    or as mentioned:
    Device.OpenUri(new Uri("tel:"+HttpUtility.UrlEncode("*804#")));

  • loladekingloladeking Member ✭✭

    @MohammedAbdalhakam said:

    It has, try PhoneDialer class (Xamarin.Essentials), USSD can be treated as a call, remember however that number must be url-encoded e.g.

    PhoneDialer.Open(HttpUtility.UrlEncode("*804#"));

    or as mentioned:
    Device.OpenUri(new Uri("tel:"+HttpUtility.UrlEncode("*804#")));

    This worked perfectly

Sign In or Register to comment.