Skip to content
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

Merged
merged 7 commits into from Apr 30, 2024

Conversation

ashwinkumar6
Copy link
Contributor

@ashwinkumar6 ashwinkumar6 commented Feb 15, 2024

Description of changes

Add custom RN implementation for android and ios to fetch device name. Implementation references taken from

output
android (model): 'sdk_gphone64_arm64'
iOS (name): 'iPhone' / '<user's iPhone>'

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

  • PR description included
  • yarn test passes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ashwinkumar6 ashwinkumar6 requested a review from a team as a code owner February 15, 2024 01:27
Copy link
Contributor

@jimblanc jimblanc left a 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
Copy link
Contributor

@HuiSF HuiSF Apr 23, 2024

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?

Copy link
Contributor Author

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

@ashwinkumar6 ashwinkumar6 merged commit 36b5d1e into aws-amplify:main Apr 30, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants