Skip to content

Commit 7bf2ac2

Browse files
davkutalekishuah
authored andcommitted
169237837 info about new and updated features (#9)
* Create pending_transaction_listener.html * Update ussd.md * More details info about different action types * Add more customization options * Add info about running 2 sessions
1 parent 93adfe0 commit 7bf2ac2

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<figure>
2+
<pre><code class="java" data-lang="java">private void callHover() {
3+
LocalBroadcastManager.getInstance(context).registerReceiver(pendingTransactionReceiver, new IntentFilter("PENDING_TRANSACTION_CREATED"));
4+
startActivityForResult(createHoverIntent(), 0);
5+
}
6+
private final BroadcastReceiver pendingTransactionReceiver = new BroadcastReceiver() {
7+
@Override
8+
public void onReceive(final Context context, final Intent i) {
9+
Log.i(TAG, "Recieved pending transaction created broadcast");
10+
Log.i(TAG, "uuid: " + i.getStringExtra("uuid");
11+
}
12+
};</code></pre>
13+
</figure>

actions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ Choose the **type** of menu that you are integrating. There are four types:
3434

3535
2. ###### SIM Toolkit
3636

37-
A SIM Toolkit (STK) based menu. Primarily for Safaricom MPESA in Kenya, but there are others.
37+
A SIM Toolkit (STK) based menu. Primarily for Safaricom MPESA in Kenya, but there are others. When using this option the root code is not used.
3838

3939
3. ###### USSD or STK push
4040

4141
A session that is not started by dialing a shortcode or launching the STK but is instead started by an API call. Most commonly used to enter a PIN to confirm, but there can be as many steps as needed, just like a regular USSD action.
4242

4343
4. ###### Variable Longstring
4444

45-
A USSD session that does not have menus for some choices that need to be made. For example, an airtime top-up using a scratch card might be done by dialing \*123\*voucherCode# where voucherCode is the number from the scratch card.
45+
A USSD session that does not have menus for some choices that need to be made. For example, an airtime top-up using a scratch card might be done by dialing \*123\*voucherCode# where voucherCode is the number from the scratch card. This is not recommended for general use since many networks prevent longstrings from working.
4646

4747

4848
In **root code** enter the string a user would dial to initiate the session. These usually look like \*123# or \*123\*01#.

customization.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@ permalink: /customization
77

88
#### Customize the User Interface
99

10-
When running a USSD session you can do some simple customizations to the confirm, PIN, processing and completion screens. Simply create a new style in your styles.xml file and define `colorPrimary`, `colorAccent`, and `colorPrimaryDark`. You can try defining other attributes as well, but we have not yet tested or made it easy to tell what will affect what. When making your call to HoverParameters.Builder() simply call the following method:
10+
When running a USSD session you can do some simple customizations to the confirm, PIN, processing and completion screens. You can add branding to the top of the processing screen using the following method:
11+
`Hover.setBranding(String brand_name_string, int logo_drawable, context)` This will permanently set the branding until it is called again, so it only needs to be called once, probably wherever Hover.initialize() is called. To change the colors on Hover SDK screens simply create a new style in your styles.xml file and define `colorPrimary`, `colorAccent`, and `colorPrimaryDark`. You can try defining other attributes as well, but we have not yet tested or made it easy to tell what will affect what. When making your call to HoverParameters.Builder() simply call the following method:
1112

1213
new HoverParameters.Builder(this).request("action_id").style(R.style.YOUR_STYLE);
1314

15+
#### Customize the Text
1416

15-
Normally the final USSD message is shown at the end so that the user can see the result of the session. This message can contain errors from the operator or tell the user that their request is being processed. However, in some cases this message is not helpful and you may want to prevent it from being displayed and display your own screen instead. To do this just add the following method to your HoverParameters.Builder call:
17+
Normally "Transaction in progress" and "processing" are shown on the screen while the USSD session is run. Change "Transaction in progress" by calling `setHeader(string)` and change "processing" by calling `initialProcessingMessage(string)` when you call HoverParameters.Builder:
1618

17-
new HoverParameters.Builder(this).request("action_id").hideFinalUssd(true);
18-
19+
new HoverParameters.Builder(this).setHeader("Working").initialProcessingMessage("please wait");
20+
21+
You can also change the "processing" message for each step. In your action add a description to each step in your action configuration, then on HoverParameters.Builder call `showUserStepDescriptions(true)`. By default, the final USSD message is shown at the end of a session so that the user can see the result. This message can contain errors from the operator or tell the user that their request is being processed. However, in some cases this message is not helpful and you may want to prevent it from being displayed or display your own message instead. To prevent any message from displaying:
22+
23+
new HoverParameters.Builder(this).request("action_id").finalMsgDisplayTime(0);
24+
25+
The argument is the number of ms, so the same method can also be used to display the message for a shorter or longer period of time. The default is 5000 ms (5 seconds). If you want to display your own message this is done by creating a [parser](/parsing) for the final USSD message and setting the "User Message" field.
1926

2027
#### Customize Accessibility
2128

@@ -25,4 +32,4 @@ If you wish to change the text that appears when a user goes to the Accessibilit
2532

2633
You can translate the strings that are part of Hover's UI components. The list of string resources to translate are in the root folder of the Hover SDK's aar packaging called `public.txt` you can find the current english value of those strings in `/res/values/values.xml`
2734

28-
[Next: Hover Tester](/hover-tester)
35+
[Next: Hover Tester](/hover-tester)

ussd.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ By using `startActivityForResult()` you will get the content of the session once
1717

1818
If the `resultCode` is `RESULT_OK` then the USSD session was successfully initiated. You can find out the details of the session and whether it successfully completed by inspecting the intent extras provided and parsing the text (see [below](#result)). If the result code is `RESULT_CANCELED` then something went wrong before starting the session. In this case the data intent returned will have a String Extra called `error` which will contain the error message.
1919

20+
In some cases a transaction confirmation based on a [parser](/parsing) can come before `onActivityResult` is called. If you need to know about the pending transaction first then you can listen for the local broadcast intent fired when the pending transaction is first created. This should come before any confirmation and has all the same details about the transaction as onActivityResult.
21+
22+
{% include pending_transaction_listener.html %}
23+
24+
Don't forget to unregister your reciever when your activity is destroyed.
25+
2026
#### Getting a Session Result
2127

2228
The data intent returned in `onActivityResult()` contains the following information if the result is `RESULT_OK`
@@ -45,4 +51,8 @@ If you do not have access to the SIM card or network you wish your users to use
4551

4652
If your USSD session does not seem to be running correctly and you want more visibility into what is happening you can activate the SDK debug environment by calling `.setEnvironment(HoverParameters.DEBUG_ENV)` on your `HoverParameters.Builder()`. This will prevent the Screen Blocker from displaying, allowing you to see the USSD session as it happens, and adding more logging information to the logcat. Do not interact with the session when you see it in this mode; if nothing happens you should recheck your action configuration. If it still doesn't work it is most likely a device specific issue, try with a different device and contact us so we can check the device and help you out. Please do not run debug mode in production: when users see the USSD messages flash across the screen it scares them, the blocking processing screen should always be in place.
4753

48-
[Next: Parse responses](/parsing)
54+
#### Advanced Usage
55+
56+
In some cases you may need information from the USSD session before you can complete a transaction. For example you may want to get a recipients name so that the user can confirm that it is the correct recipient. To do this you currently need to create 2 separate actions. The first you will configure to run through the USSD steps until the menu that has the information you need. Make that the final step, then create a parser which pulls the details you need out of the message. Use the TRANSACTION_UPDATE broadcast to recieve this information and trigger showing it to the user. Once they have confirmed or otherwise acted based on the information you can then start a second action which you have configured to run the transaction through to completion. Please remember that in some cases your users are charged per USSD session and will not appreciate being charged twice.
57+
58+
[Next: Parse responses](/parsing)

0 commit comments

Comments
 (0)