vkammerer / ussd_service

A Flutter plugin to make USSD requests
https://pub.dev/packages/ussd_service
BSD 2-Clause "Simplified" License
21 stars 14 forks source link

Reply ussd error in multi steps #1

Closed tackelua closed 4 years ago

tackelua commented 4 years ago

Dear,

I try to use ussd_service to send ussd code and reply to messages by many steps. This lib looks like doesn't support the ussd reply feature. It returns the error USSD_RETURN_FAILURE

Please support ussd reply feature.

Thank you so much!

vkammerer commented 4 years ago

Hello,

I will need more information to be able to help you. Could you explain more in details what you have done? And have you tried the example application as shown in https://pub.dev/packages/ussd_service#-example-tab- ?

tackelua commented 4 years ago

Thank you for your reply.

You can see the images, the first image I use the app call *101# it shows the response message and waits for me to reply. The 2nd image I test with your lib and it show the error.

image

image

tackelua commented 4 years ago

I found the error when building the apk but the folder outputs/apk/release have app-release.apk

Here the log

$ flutter build apk
You are building a fat APK that includes binaries for android-arm,
android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app
bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform
        android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform
        android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:
        https://developer.android.com/studio/build/configure-apk-splits#configur
        e-abi-split

FAILURE: Build failed with an exception.                                

* What went wrong:                                                      
Execution failed for task ':sim_service:verifyReleaseResources'.        
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed                                    
     /Users/gith/.gradle/caches/transforms-2/files-2.1/7faf2ad74a0b9932e38d86e684646e95/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

     /Users/gith/.gradle/caches/transforms-2/files-2.1/7faf2ad74a0b9932e38d86e684646e95/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.

* Try:                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org                              

BUILD FAILED in 7s                                                      
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                       7.6s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool
is about to try using Jetfier to solve the incompatibility.
Building plugin permission_handler...
Running Gradle task 'assembleAarRelease'...                             
Running Gradle task 'assembleAarRelease'... Done                    1.6s

FAILURE: Build failed with an exception.

* What went wrong:
Task 'assembleAarRelease' not found in root project 'permission_handler'.

* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

The plugin permission_handler could not be built due to the issue above.
vkammerer commented 4 years ago

Thank you for your reply, that helps a lot. I have never tested my plugin for an interactive / multi steps session, but I have been wondering wether it would work or not.. This plugin is only a wrapper over Android's sendUssdRequest , and it looks like it isn't handling well a multi session: as you can see at https://github.com/vkammerer/ussd_service/blob/master/android/src/main/java/com/vincentkammerer/ussd_service/UssdServicePlugin.java#L65 , the response you are getting from my plugin is only a propagation from Android's own response. Are you able to make sure that the arguments you pass to makeRequest are correct? maybe with the following steps:

tackelua commented 4 years ago

I added 2 fields in UI and it show the arguments are correct.

 dynamic _subscriptionId;
 dynamic _requestedCode;
 setState(() {
        _subscriptionId = simData.cards.first.subscriptionId;
        _requestedCode = _requestCode;
 });
 Text("\n_subscriptionId: ${_subscriptionId} type: ${_subscriptionId.runtimeType}"),
 Text("\n_requestedCode: ${_requestedCode} type: ${_requestedCode.runtimeType}"),

I used _subscriptionId.runtimeType to determine the type of variable and it shows the arguments are correct.

image

vkammerer commented 4 years ago

Ok thank you, your debugging steps help a lot. As far as I can see, it looks like Android's sendUssdRequest method doesn't handle well multi steps sessions, since the error code you are getting is returned only at https://github.com/vkammerer/ussd_service/blob/master/android/src/main/java/com/vincentkammerer/ussd_service/UssdServicePlugin.java#L65 .

I have done some googling in the meantime and can't find any official documentation explaining wether this is supported, but this thread is very interesting: https://androidforums.com/threads/how-to-use-api-27-telephony-manager-ussd-feature.1271192/ . According to comment #10, it looks like Android is executing the correct initial request but that it is incapable of interpreting the response as valid. And according to comment #13, it looks like setting all the parameters in the initial request can be a good solution: https://androidforums.com/threads/how-to-use-api-27-telephony-manager-ussd-feature.1271192/#post-7762499

So a potential solution could maybe be to execute the USSD request with all the parameters at once? Is that something that suit your use case? If yes, I guess that one first step could be to try it out in the call app first, and then to try it using my plugin.

tackelua commented 4 years ago

@vkammerer thank you because of your links. I try and found the syntax ussd for multi steps like that

*firstCode*2ndCode*3rdCode*4thCode*..*..#

Start with * then code and * code .. and end with #

vkammerer commented 4 years ago

Ok great, so your application is working like that?

yonas1104 commented 3 years ago

whether its silent USSD requests or not I won't mind, I want to make ussd request and get a response that works on both android and ios can you please please please help me?

YoanisWolde commented 3 years ago

does this plugin work for dual sim? i tried to use simData.cards.last.subscriptionId but it run only in SIM 1. any help? please.

vkammerer commented 3 years ago

@yonas1104 this plugin does not plan to implement a non silent way to make USSD requests so you may have to do some research to find out how to implement it on iOS.

@john-github-2020 I believe your issue applies to the sim_data plugin so your question would ideally be asked in its repository. At first sight it seems that you make assumptions about the order of your cards in simData.cards but what you call SIM 1 may be the last in that list? I may be able to help more if you create an issue in the sim_data repo.

Teklehaimanot commented 3 years ago

i am using the request code that needs a user confirmation , how can i passed this confirmation number by inputting appropriate value automatically

YoanisWolde commented 3 years ago

is there any way to display the result in alert dialog?

gausoft commented 3 years ago

is there any way to display the result in alert dialog?

I guess you will handle It your self

ArthurMagma commented 2 months ago

i am using the request code that needs a user confirmation , how can i passed this confirmation number by inputting appropriate value automatically

i have the same probleme. do you find solution?

ArthurMagma commented 2 months ago

Ok thank you, your debugging steps help a lot. As far as I can see, it looks like Android's sendUssdRequest method doesn't handle well multi steps sessions, since the error code you are getting is returned only at https://github.com/vkammerer/ussd_service/blob/master/android/src/main/java/com/vincentkammerer/ussd_service/UssdServicePlugin.java#L65 .

I have done some googling in the meantime and can't find any official documentation explaining wether this is supported, but this thread is very interesting: https://androidforums.com/threads/how-to-use-api-27-telephony-manager-ussd-feature.1271192/ . According to comment #10, it looks like Android is executing the correct initial request but that it is incapable of interpreting the response as valid. And according to comment #13, it looks like setting all the parameters in the initial request can be a good solution: https://androidforums.com/threads/how-to-use-api-27-telephony-manager-ussd-feature.1271192/#post-7762499

So a potential solution could maybe be to execute the USSD request with all the parameters at once? Is that something that suit your use case? If yes, I guess that one first step could be to try it out in the call app first, and then to try it using my plugin.

hello! hope you are fine. do you find solution for the ussd multi step please?

ArthurMagma commented 2 months ago

I added 2 fields in UI and it show the arguments are correct.

 dynamic _subscriptionId;
 dynamic _requestedCode;
 setState(() {
        _subscriptionId = simData.cards.first.subscriptionId;
        _requestedCode = _requestCode;
 });
 Text("\n_subscriptionId: ${_subscriptionId} type: ${_subscriptionId.runtimeType}"),
 Text("\n_requestedCode: ${_requestedCode} type: ${_requestedCode.runtimeType}"),

I used _subscriptionId.runtimeType to determine the type of variable and it shows the arguments are correct.

image

hello! hope you are fine. do you find solution for the ussd multi step please?