5. Enabling Detections
After creating a Sentiance user, you can enable SDK detections. This will allow the Sentiance SDK to run in the background, and intelligently detect a user's real-world movements, while collecting sensor, location, and motion activity data.
import { enableDetections } from '@sentiance-react-native/core';
try {
const result = await enableDetections();
console.log(`SDK detection status is now ${result.detectionStatus}`);
} catch(e) {
console.log('Failed to start detections: ' + e);
}
After detections are successfully enabled, you can determine whether the SDK is able to detect, by checking the detection status:
const detectionStatus = result.detectionStatus;
switch() {
case 'ENABLED_AND_DETECTING':
// Detections are enabled and running
break;
case 'ENABLED_BUT_BLOCKED':
// Detections are enabled but blocked
break;
default:
// Detections weren't enabled
}
If detections are blocked, you can check the SDK status to see what's blocking them. Usually, this is caused by insufficient permissions or a disabled location tracking.
Last updated