-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getSerialNumberSync api error? #1056
Comments
I fixed your code block so it was readable - triple-backticks are your friend https://www.markdownguide.org/extended-syntax#syntax-highlighting The API is only available from API26 on. https://developer.android.com/reference/android/os/Build#getSerial() |
this is better? if (Build.VERSION.SDK_INT >= 26) {
...
} else {
return Build.SERIAL;
} |
Please read the docs for the API you propose: https://developer.android.com/reference/android/os/Build#SERIAL
So, no, that won't help. Getting hardware identifiers is a losing proposition, you're fighting the operating systems now. They don't want to give you hardware identifiers. My best advice is to stop trying. Use something like Firebase Instance ID or similar |
ok, thanks |
We're deploying a lot of Sunmi V2 devices, which allow access to the serial number via BUILD.SERIAL. I don't see a reason to not have the else statement and return BUILD.SERIAL if it isn't unknown? |
In case someone stumbles across this from Google and is in the same very specific sitation: Add this to
Grab these two packages:
Then add a postinstall script:
|
Fascinating, I suppose if some hardware is actually returning it (quite unexpected / contrary to the API docs...) adding an else would be acceptable. If you PR it I'll merge it @stewartmcgown |
I should add that this is specifically on Android 7, which the devices are stuck on. I understand this is the last version where BUILD.SERIAL was populated Vs getSerial |
…1056) Following the disussion in react-native-device-info#1056 this will allow users of old MDM devices like the Sunmi V2 and others to access serial numbers via their privileged system access permissions assigned by the MDM. This shouldn't cause any problems as the Build.SERIAL will be populated with 'unkown' regardless of permissions.
@mikehardy tiny pr submitted! |
all PRs are mighty! 😆 - thanks |
Following the disussion in #1056 this will allow users of old MDM devices like the Sunmi V2 and others to access serial numbers via their privileged system access permissions assigned by the MDM. This shouldn't cause any problems as the Build.SERIAL will be populated with 'unkown' regardless of permissions.
## [8.0.7](v8.0.6...v8.0.7) (2021-03-24) ### Bug Fixes * get legacy serial number for old APIs ([#1056](#1056)) ([40aa45b](40aa45b))
## [8.0.7](react-native-device-info/react-native-device-info@v8.0.6...v8.0.7) (2021-03-24) ### Bug Fixes * get legacy serial number for old APIs ([#1056](react-native-device-info/react-native-device-info#1056)) ([933c551](react-native-device-info/react-native-device-info@933c551))
## [8.0.7](react-native-device-info/react-native-device-info@v8.0.6...v8.0.7) (2021-03-24) ### Bug Fixes * get legacy serial number for old APIs ([#1056](react-native-device-info/react-native-device-info#1056)) ([40aa45b](react-native-device-info/react-native-device-info@40aa45b))
Bug report
when android SDK < 26, getSerialNumberSync() always return "unknown"?
Environment info
react-native info
output:The text was updated successfully, but these errors were encountered: