0

please help me with sending ussd request.

IReadOnlyList<string> networkAccIds = MobileBroadbandAccount.AvailableNetworkAccountIds;
if (networkAccIds.Count == 0)
{
    return;
}
string networkAccountId = networkAccIds[0];
UssdSession session = UssdSession.CreateFromNetworkAccountId(networkAccIds[0]);

2 sim card installed in my phone. But networkAccIds.Count always zero. What's my mistake?

update 1:

Thanks Jerry Li. I got the network identifiers. I have a new problem. When I do:

UssdReply reply = await session.SendMessageAndGetReplyAsync(new UssdMessage("*100#")); 

I get exception:

Unexpected exception occured: System.Runtime.InteropServices.COMException (0x80070032): The request is not supported.

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()


   at uwp_1.MainPage.<GetBalance>d__1.MoveNext()

Why do I get exception?

1 Answer 1

0

2 sim card installed in my phone. But networkAccIds.Count always zero. What's my mistake?

You are accessing privileged APIs (UssdSession and MobileBroadbandAccount) used by mobile broadband operators. It requires a special-use capability to be declared in package manifest:

<Capabilities>
  <r:Capability Name="cellularDeviceIdentity"/>
  <r:Capability Name="cellularDeviceControl"/>
  <r:Capability Name="cellularMessaging"/>
</Capabilities>

Please make sure you have declared the corresponding special-use capabilities in package manifest. And the Mobile broadband sample which shows how to use the Mobile Broadband Networking API is for your reference.

In addition:

Your app will work and you can test it on your phone, but it will not pass WACK (Windows App Certification Kit) because it uses a special-use capability. This kind of apps can be used in Company app(Don’t need to publish to Windows Store), MS internal or OEM/partner.

3
  • Thank you, but I have new problem. I have exception, when I call the method SendMessageAndGetReplyAsync.
    – user6307007
    May 9, 2016 at 18:12
  • You are welcome :) About the new exception, you were not calling the method SendMessageAndGetReplyAsync properly: UssdReply reply = await session.SendMessageAndGetReplyAsync(new UssdMessage("*100#")); UssdResultCode code = reply.ResultCode; And the USSD protocol sample is for your reference.
    – Jerry Li
    May 10, 2016 at 2:24
  • Did you manage to resolve your problem, I've the exact same problem. Aug 1, 2018 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.