-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(react-native): add getDeviceName util #13015
Conversation
4cb6f1e
to
5b6c2b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the example in the description: <user's iPhone>
Would this be something like: "Jim's iPhone". I'm worried about potential UCI implications here. Blocking PR until we can confirm.
func getDeviceName(resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) { | ||
var deviceName: String | ||
#if canImport(UIKit) | ||
deviceName = UIDevice.current.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use of the name
getter of the UIDevice
class requires the host app to be assigned with a corresponding entitlement (when running on iOS 16.0+) otherwise it returns the generic string "iPhone"
, are we going to instruct developers to do so in order to use this API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should instruct developers to add a corresponding entitlement to use the API since it defaults to a generic device name, example "iPhone"
We could add a callout saying by default
- iOS 15 and earlier: name configured on device "Bob's iPhone X" (iPhone settings>General>About>Name)
- iOS 16 and later: a generic device name "iPhone"/"iPad". Optionally an entitlement is required to get actual device name
Description of changes
Add custom RN implementation for android and ios to fetch device name. Implementation references taken from
PS: on ios a generic value like 'iPhone' is returned unless a entitlement is added (reference)
Description of how you validated changes
Tested API output on android emulator and ios simulator
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.