From release version 1.11.2 onwards, the RetailForce Fiscalisation Service (‘middleware’) will also be available as a native service for Android.
You can find the Android service in the downloads section of the RetailForce website for the respective version (retailforce.trustedfiscalmodule-Signed.apk).
Installation
To install the Android service, download it onto the relevant device. To install the service, you must set the installation permission (‘Trust this source’).
After installation, the service runs automatically.
You can also distribute the APK file via an MDM (Mobile Device Management) system.
Integration
The RetailForce Fiscalisation Service for Android runs as a Foreground Service.
To connect to the RetailForce service for Android, the app must perform the following steps:
- Permissions in AndroidManifest.xml
``` xml
<uses-permission android:name="cloud.retailforce.trustedfiscalmodule.RetailForceService.BIND_RETAILFORCE" />
<queries>
<package android:name="cloud.retailforce.trustedfiscalmodule" />
</queries>
```
- Call the RetailForce Service for Android (example for C#, but similar in Java / Kotlin)
``` csharp
var intent = new Intent();
ComponentName componentName = new ComponentName("cloud.retailforce.trustedfiscalmodule", "cloud.retailforce.trustedfiscalmodule.RetailForceService");
intent.SetComponent(componentName);
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
{
StartForegroundService(intent);
}
else
{
StartService(intent);
}
```
- Bind to the RetailForce Service for Android
``` csharp
ServiceConnection serviceConnection = new ServiceConnection();
if (!BindService(intent, serviceConnection, Android.Content.Bind.AutoCreate | Android.Content.Bind.AllowActivityStarts))
{
_logger.LogInformation("Bind service failed");
throw new Exception("Could not bind RetailForceService");
}
```
- Ask for permission.
It might be necessary to ask for permission to call a Foreground service (starting from Android 13).
``` csharp
if (Build.VERSION.SdkInt >= BuildVersionCodes.Tiramisu)
{
if (CheckSelfPermission(Android.Manifest.Permission.ForegroundService) != Permission.Granted)
{
RequestPermissions(new[] { Android.Manifest.Permission.ForegroundService }, 101);
}
}
```
The RetailForce service for Android runs at http://127.0.0.1:7678/api/v1/ and can be accessed via REST (just like the RetailForce Fiscalisation REST service on Windows, Docker, or Cloud Fiscalisation Service).
Different android versions
Currently, the RetailForce service for Android has only been tested on Android 14 and 15.
For older Android versions, it may be necessary to slightly adjust the code, especially with regard to permissions and service binding.
Troubleshooting
To check the general function of the middleware or for error handling, it can be helpful to use the command line tool ‘Android Debug Bridge (ADB)’, e.g. under Windows.
To do this, ADB for Windows must be available in a directory on your computer.
- Connect the Android device to the Windows PC via USB,
- open a command prompt in the ADB directory,
- and enter the following command:
adb logcat "RetailForceService:D *:S"This command displays all log entries as you would normally find them in the log files of the Windows or Docker service.
Comments
0 comments
Please sign in to leave a comment.