Main configurations

Permission management

On iOS, the user must grant access permission to the phone's location in background to enable the trip detection function included in the Trip Analysis component. There are several options for this permission and automatic mode will only work if the user selects the "Always" option.
The Permissions Utils component provides a set of screens to guide the user through the selection of the right options. Once the user has correctly authorized access to the location, you are warned by the closure passed in parameter:
1
DriveKitPermissionsUtilsUI.shared.getLocationPermissionViewController {
2
// Code called when location permission is properly granted.
3
}
Copied!
It is also recommended that the user allows access to activity recognition (aka "Motion and fitness"). The Permissions Utils component contains a dedicated screen to help the user:
1
DriveKitPermissionsUtilsUI.shared.getActivityPermissionViewController {
2
// Code called when activity permission is properly granted.
3
}
Copied!
The method below helps you to configure the required permission requests and the order in which they are displayed. You will be notified when the requested permissions are successfully granted:
1
DriveKitPermissionsUtilsUI.shared.showPermissionViews([.location, .activity], parentViewController: <UINavigationController>) {
2
// Code called when permissions (here: "location" and "activity"), are both properly granted.
3
}
Copied!

SDK diagnosis

The diagnosis screen is divided into four areas:
    1.
    The first displays the status of sensors and permissions.
    2.
    The second contains a quick link to the battery optimization functions.
    3.
    The third displays a contact button to reach support.
    4.
    The fourth section allows you to enable an activity log.
Layout of the diagnosis screen on iOS
The first two areas are always displayed. The third and fourth are optional.
The diagnosis function of the SDK has the following configurations:
    In area 1, the sensors and permissions to be checked are selected automatically except for the Bluetooth sensor. If your application does not use a Bluetooth device or an iBeacon, it is not necessary to monitor the status of the Bluetooth sensor.
    Area 2 is always displayed. If battery optimization is enabled, a link will appear to redirect the user to the phone settings. The user will have to open the battery settings to disable the optimization.
    In area 3, it is possible to configure the recipient's email address for the support request or a web address to which the user can be directed.
    Area 4 can be hidden if necessary.

Bluetooth sensor status check

Access to the Bluetooth sensor is not required on iOS. This permission is not requested when the application is first installed.
For natural triggering (i.e. from the phone's sensors), or using an iBeacon, Bluetooth access is not required.
Access to the Bluetooth sensor is required in the two cases described below:
    1.
    To enable automatic start of trip recording from a Bluetooth device.
    2.
    To measure the battery level of an iBeacon device.
By default, access to the Bluetooth sensor is not monitored. But if you want to check it, add the following line after the initialization when configuring the module in the AppDelegate:
1
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2
DriveKitUI.shared.initialize()
3
DriveKitPermissionsUtilsUI.shared.initialize()
4
...
5
DriveKitPermissionsUtilsUI.shared.configureBluetooth(needed: true)
6
}
Copied!

Support Request Management

The user can make a support request if the application does not work properly.
When the user clicks on the support request button, you can choose between two actions:
    1.
    An email will be automatically composed,
    2.
    or a redirection to a web page of your choice will be made.
The email contains the key information to ease the diagnosis of a problem (status of permissions and phone sensors). The recipient's email is configurable, as well as other parameters:
1
import DriveKitCoreModule
2
import DriveKitCommonUI
3
import DriveKitPermissionsUtilsUI
4
5
@UIApplicationMain
6
class AppDelegate: UIResponder, UIApplicationDelegate {
7
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
8
DriveKitUI.shared.initialize()
9
DriveKitPermissionsUtilsUI.shared.initialize()
10
...
11
DriveKitPermissionsUtilsUI.shared.configureContactType(
12
DKContactType.email(MailConfiguration())
13
)
14
}
15
}
16
17
class MailConfiguration : DKContentMail {
18
func getRecipients() -> [String] {
20
}
21
22
func getBccRecipients() -> [String] {
23
[]
24
}
25
26
func getSubject() -> String {
27
"[App] Technical support request"
28
}
29
30
func getMailBody() -> String {
31
""
32
}
33
34
func overrideMailBodyContent() -> Bool {
35
false
36
}
37
}
Copied!
If you don’t want the email body to contain information about the state of permissions and sensors, then return “true” in the method “overrideMailBodyContent()”.
If you want to redirect the user to a web page instead of composing an email, you have to add the following line:
1
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2
DriveKitUI.shared.initialize()
3
DriveKitPermissionsUtilsUI.shared.initialize()
4
...
5
DriveKitPermissionsUtilsUI.shared.configureContactType(DKContactType.web(<url>))
6
}
Copied!
In this specific case, there is no way to obtain information about authorization and sensor status.
If you do not configure the contact type, this area will be hidden and will not appear on the diagnosis screen.

Activity log

If necessary, the user can enable the activity log. This feature records key events in a file. This data will be helpful to analyse in detail the cause of a problem occurring in the application.
The activity log file is automatically added as an attachment to the support request email (which has been configured in the previous section).
This feature is configurable. By default, this feature is not displayed. To activate it, call the following line:
1
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2
DriveKitUI.shared.initialize()
3
DriveKitPermissionsUtilsUI.shared.initialize()
4
...
5
DriveKitPermissionsUtilsUI.shared.configureDiagnosisLogs(show: true)
6
}
Copied!
For more details on the DriveKit logging function, go to the logging page.
Last modified 1yr ago