Passwordless SMS Localization Fails on Android but Works on iOS

Overview

This article addresses an issue where Passwordless Short Message Service (SMS) localization fails for Android devices but functions correctly for iOS devices when using the React Native Software Development Kit (SDK) v4.4.0. Specifically, when initiating the passwordless flow via a POST /passwordless/start request with a specific language preference (e.g., French), the SMS message received on Android devices is in English, while the message received on iOS devices correctly reflects the chosen language.

Here is the screenshot of the message on the Android device:

Applies To

  • Passwordless SMS
  • Localization
  • Android Devices
  • React Native SDK v4.4.0

Cause

The accept-language header is present in the network requests originating from iOS devices but is missing from requests originating from Android devices. iOS automatically includes the accept-language header based on the device’s language settings, whereas Android does not add this header by default.

Solution

To ensure Passwordless SMS localization functions correctly on Android devices, explicitly include the accept-language header in the POST /passwordless/start request. Below is an example script demonstrating how to add the header:

import { Platform } from 'react-native';

 

const sendPasswordlessSMS = async (phoneNumber) => {

const url = 'https://{auth0_domain}/passwordless/start';

 

const payload = {

phone_number: phoneNumber,

send: 'code',

connection: 'sms',

client_id: {application_client_id}

};

 

try {

const response = await fetch(url, {

method: 'POST',

headers: {

'Content-Type': 'application/json',

// Explicitly setting Accept-Language to French (Canada)

'Accept-Language': 'fr-CA',

},

body: JSON.stringify(payload),

});

 

const data = await response.json();

console.log('SMS sent response:', data);

} catch (error) {

console.error('Error sending SMS:', error);

}

};

NOTE: A backlog item exists internally to allow passing headers directly through the SDK’s API call. An estimated time for availability is not yet determined.