feat(native): use expo-device for reliable device-info headers

Constants.platform.ios.model returns only generic "iPhone" instead of
"iPhone 15 Pro" + osVersion was unreliable. Switched lib/deviceId.ts to
expo-device which exposes Device.deviceName ("iPhone von Chahine"),
Device.modelName ("iPhone 15 Pro") and Device.osVersion ("26.4.2") on real
devices. Constants stays as fallback for Simulator/Web.

Backend touchDevice + auto-register already backfill these fields from the
x-device-* headers (commit 60f608d) — but only with proper Frontend values
which Constants couldn't provide.

Requires new native build (versionCode 8) since expo-device is a native
module — current TestFlight build (7) still ships with old Constants logic.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
chahinebrini 2026-05-15 21:45:33 +02:00
parent 60f608d891
commit cd5efab6e1
3 changed files with 28 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import { Platform } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as Application from 'expo-application';
import * as Device from 'expo-device';
import Constants from 'expo-constants';
const STORAGE_KEY = 'rebreak_device_id';
@ -63,17 +64,22 @@ export async function getDeviceInfo(): Promise<DeviceInfo> {
const deviceId = await getDeviceId();
const platform = getPlatformName();
// expo-device returnt zuverlässige Hardware-Infos auf realen Devices.
// Constants ist Fallback für Simulator/Web (Device-APIs sind dort null).
const name =
Device.deviceName ||
(Constants as any).deviceName ||
Constants.platform?.ios?.model ||
Device.modelName ||
platform;
const model =
Device.modelName ||
Device.modelId ||
Constants.platform?.ios?.model ||
Constants.platform?.android?.versionCode?.toString() ||
platform;
const osVersion =
Device.osVersion ||
Constants.platform?.ios?.systemVersion?.toString() ||
(Platform.Version as string | number)?.toString() ||
'';

View File

@ -32,6 +32,7 @@
"expo-clipboard": "^8.0.8",
"expo-constants": "~18.0.13",
"expo-dev-client": "~6.0.21",
"expo-device": "^55.0.17",
"expo-file-system": "~19.0.22",
"expo-font": "~14.0.11",
"expo-haptics": "^15.0.8",

19
pnpm-lock.yaml generated
View File

@ -180,6 +180,9 @@ importers:
expo-dev-client:
specifier: ~6.0.21
version: 6.0.21(expo@54.0.34)
expo-device:
specifier: ^55.0.17
version: 55.0.17(expo@54.0.34)
expo-file-system:
specifier: ~19.0.22
version: 19.0.22(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.2.14)(react@19.1.0))
@ -5526,6 +5529,11 @@ packages:
peerDependencies:
expo: '*'
expo-device@55.0.17:
resolution: {integrity: sha512-ZcMrSeD0zWooosm5Bet5qluxUrhw+NPgcMmN6ySVF7cm4K8Bvh4KPogJePbI1qfhFAiJWcWeV9e/2uewb9ktfw==}
peerDependencies:
expo: '*'
expo-file-system@19.0.22:
resolution: {integrity: sha512-l9pgahSc7sJD0bP9vBNeXvZjy8QKDpVHVxWmei/ESQOrzmoj5BidziqLVsyZdxsi+PfdbTtttLTAmddH/JafYA==}
peerDependencies:
@ -8778,6 +8786,10 @@ packages:
engines: {node: '>=14.17'}
hasBin: true
ua-parser-js@0.7.41:
resolution: {integrity: sha512-O3oYyCMPYgNNHuO7Jjk3uacJWZF8loBgwrfd/5LE/HyZ3lUIOdniQ7DNXJcIgZbwioZxk0fLfI4EVnetdiX5jg==}
hasBin: true
ufo@1.6.1:
resolution: {integrity: sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==}
@ -15519,6 +15531,11 @@ snapshots:
expo: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.2.14)(react@19.1.0))(react@19.1.0)(typescript@5.8.3)
expo-dev-menu-interface: 2.0.0(expo@54.0.34)
expo-device@55.0.17(expo@54.0.34):
dependencies:
expo: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.2.14)(react@19.1.0))(react@19.1.0)(typescript@5.8.3)
ua-parser-js: 0.7.41
expo-file-system@19.0.22(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.2.14)(react@19.1.0)):
dependencies:
expo: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.2.14)(react@19.1.0))(react@19.1.0)(typescript@5.8.3)
@ -19505,6 +19522,8 @@ snapshots:
typescript@5.9.3: {}
ua-parser-js@0.7.41: {}
ufo@1.6.1: {}
ufo@1.6.4: {}