setDeviceToken
š² Ditto ID SDK API: setDeviceToken
setDeviceTokenš Description
The setDeviceToken API is used to register the device's push notification token (FCM, APNS, or HCM) with the Ditto ID SDK. This enables the device to receive push-based verification notifications. This API must be called before the onUserLoggedIn event is triggered.
š§ Parameters
| Platform | Parameter | Description |
|---|---|---|
| React Native | deviceToken | JSON string (for HCM) or plain string (for FCM) |
| Flutter | deviceToken | Stringified Map for HCM or direct token for FCM/APNS |
| Cordova | deviceToken | JSON string (for HCM) or plain string (for FCM) |
| iOS / Android Native | ā Not needed | Native platforms auto-handle token registration |
š» Platform Usage
React Native
// FCM token
RdnaClient.setDeviceToken("<FCM_TOKEN>", (syncResponse) => {});
// HCM token
let json = {
deviceToken: "<HCM_TOKEN>",
pnsType: "HCM"
};
RdnaClient.setDeviceToken(JSON.stringify(json), (syncResponse) => {});Flutter
// FCM/APNS token
rdnaClient.setDeviceToken("<TOKEN>");
// HCM token
Map<String, dynamic> token = {
'deviceToken': "<HCM_TOKEN>",
'pnsType': "HCM"
};
rdnaClient.setDeviceToken(token.toString());Cordova
// FCM token
com.uniken.rdnaplugin.RdnaClient.setDeviceToken(successCallback, errorCallback, ["<FCM_TOKEN>"]);
// HCM token
let json = {
deviceToken: "<HCM_TOKEN>",
pnsType: "HCM"
};
com.uniken.rdnaplugin.RdnaClient.setDeviceToken(successCallback, errorCallback, [JSON.stringify(json)]);š Note
- This API must be invoked before the
onUserLoggedInevent. - If not called, push notifications like device verification or consent challenges will not be delivered.
ā
On Success
- Token registered successfully.
- Device is now ready to receive Ditto Verify notifications.
ā On Failure
- Ensure token format is valid.
- Check connectivity or SDK initialization.
Updated 4 months ago
