getDeviceToken

📲 REL-ID SDK Event: getDeviceToken

📋 Description

The getDeviceToken callback is invoked by the SDK on native iOS and Android platforms. It is triggered before theonUserLoggedIn event and is intended for the application to provide a valid push notification token (APNS for iOS or FCM/HCM for Android) back to the SDK.

This event is only relevant for Native iOS and Native Android platforms. React Native, Flutter, and Cordova developers are expected to use the setDeviceToken() API instead.


🧠 Purpose

  • To allow the app to retrieve and return the device token to the SDK.
  • Ensures the device is registered to receive push notifications for verification and authentication flows.

🧾 Platform-specific Usage

Native iOS

  • Triggered by SDK to request APNS device token
  • Pseudocode:
(NSString *)getDeviceToken;

The app must return the APNS device token as a string.


Native Android

  • Triggered by SDK to request HCM/FCM token
  • Pseudocode:
String getDeviceToken();

The app must return either a plain FCM token or a JSON string with deviceToken and pnsType for HCM.

// For HCM token
JSONObject json = new JSONObject();
json.put("deviceToken", "<HCM_TOKEN>");
json.put("pnsType", "HCM");
return json.toString();

// For FCM token
return "<FCM_TOKEN>";

🚫 Not Applicable To

  • React Native
  • Flutter
  • Cordova

These platforms should use the setDeviceToken() API instead.


✅ Developer Responsibility

  • Ensure the token is fetched from FCM/HCM/APNS before this event is triggered.
  • Return a valid push token string as required by the platform.