反应本机获取ios设备语言
我正在尝试从ios设备获取当前区域设置 当我创建我的项目并使用expo时,我遵循了这一点 我尝试了以下代码反应本机获取ios设备语言,ios,reactjs,react-native,Ios,Reactjs,React Native,我正在尝试从ios设备获取当前区域设置 当我创建我的项目并使用expo时,我遵循了这一点 我尝试了以下代码 if (Platform.OS === "android") { langRegionLocale = NativeModules.I18nManager.localeIdentifier || ""; } else if (Platform.OS === "ios") { langRegionLocale = NativeModules.SettingsManag
if (Platform.OS === "android") {
langRegionLocale = NativeModules.I18nManager.localeIdentifier || "";
} else if (Platform.OS === "ios") {
langRegionLocale = NativeModules.SettingsManager.settings.AppleLocale || "";
}
而且它在android上运行,但在iPhone上测试时,它不起作用,并且在我登录时说设置管理器未定义
如何在不弹出或使用的情况下获取ios的当前区域设置
如果可能的话,我想使用内置的东西
下面是我的包。json
{
"name": "demoapp",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.5.0",
"jest-expo": "^21.0.2",
"react-test-renderer": "16.0.0-alpha.12"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^21.0.0",
"react": "16.0.0-alpha.12",
"react-native": "^0.48.4",
"react-navigation": "^1.0.0-beta.13",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
}
}
Expo有一种获取设备区域设置的方法
返回当前设备
区域设置为字符串
Expo有一种获取设备区域设置的方法
返回当前设备
区域设置为字符串