From cd5efab6e1ea45222548f569f25a709e5e559c8a Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Fri, 15 May 2026 21:45:33 +0200 Subject: [PATCH] feat(native): use expo-device for reliable device-info headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/rebreak-native/lib/deviceId.ts | 10 ++++++++-- apps/rebreak-native/package.json | 1 + pnpm-lock.yaml | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/rebreak-native/lib/deviceId.ts b/apps/rebreak-native/lib/deviceId.ts index 4be7e24..fbeb576 100644 --- a/apps/rebreak-native/lib/deviceId.ts +++ b/apps/rebreak-native/lib/deviceId.ts @@ -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 { 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() || ''; diff --git a/apps/rebreak-native/package.json b/apps/rebreak-native/package.json index 2d67df9..4e02045 100644 --- a/apps/rebreak-native/package.json +++ b/apps/rebreak-native/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 79c1b0a..87b6a51 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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: {}