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

deviceName not updating when user updates device name on device #1272

Closed
chrisdrackett opened this issue Jul 28, 2021 · 13 comments · Fixed by #1332
Closed

deviceName not updating when user updates device name on device #1272

chrisdrackett opened this issue Jul 28, 2021 · 13 comments · Fixed by #1332

Comments

@chrisdrackett
Copy link

Summary

Version 8.1.4
Affected OS iOS
OS Version 14.7

Current behavior

after changing the device name and then calling DeviceInfo.getDeviceName() I'm still getting the old value.

  1. open app (device name reports as iPhone)
  2. close app and change device name in settings to iPhone new
  3. open app and call DeviceInfo.getDeviceName()
  4. returns iPhone and not iPhone new

Expected behavior

DeviceInfo.getDeviceName() should report the current device name

@mikehardy
Copy link
Collaborator

That's odd. Looks like we fetch it dynamically:

- (NSString *) getDeviceName {
UIDevice *currentDevice = [UIDevice currentDevice];
return currentDevice.name;
}
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getDeviceNameSync) {
return self.getDeviceName;
}
RCT_EXPORT_METHOD(getDeviceName:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
resolve(self.getDeviceName);
}

How did it go when you reached in there and added some debugging print statements + watched the logs? Is the system API we use behaving correctly? Does it mention anything in the related documentation about caching behavior in the system?

@schie
Copy link
Contributor

schie commented Aug 6, 2021

@mikehardy in the js/ts side, it is memo-ized. We can remove the memo to resolve this issue.

@mikehardy
Copy link
Collaborator

Ah ha! @chrisdrackett if you post a PR removing the memoization there, can happily merge + release

tangent: oh man, the semantic release bot is golden here @schie, thank you so much for that

chrisdrackett added a commit to chrisdrackett/react-native-device-info that referenced this issue Aug 6, 2021
@rndi-bot
Copy link
Collaborator

rndi-bot commented Oct 5, 2021

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is sti ll here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solu tions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

@rndi-bot rndi-bot added the stale label Oct 5, 2021
@schie schie reopened this Oct 12, 2021
@schie schie added the Keep Open avoid the stale bot label Oct 12, 2021
@rndi-bot rndi-bot removed the stale label Oct 12, 2021
schie added a commit that referenced this issue Oct 25, 2021
removes memoization of device name because the device's name can be changed

resolves #1272

Co-authored-by: @chrisdrackett
schie added a commit that referenced this issue Oct 26, 2021
* fix(index): removing memoization of `getDeviceName`

removes memoization of device name because the device's name can be changed

resolves #1272

Co-authored-by: @chrisdrackett

* test(__tests__s/getters): changing tests for `getDeviceName`

moves function from `memoizedStringGetters` to `nonMemoizedStringGetters`
rndi-bot pushed a commit that referenced this issue Oct 26, 2021
## [8.4.3](v8.4.2...v8.4.3) (2021-10-26)

### Bug Fixes

* **getDeviceName:** un-memoize device name so it updates ([#1332](#1332)) ([7026844](7026844)), closes [#1272](#1272)
@rndi-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 8.4.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@anujwits
Copy link

This issue is still persist for android devices.
Android Version: 11
react-native-device-info: 8.7.0

Please suggest a workaround.

@mikehardy
Copy link
Collaborator

No workaround to suggest, please investigate using standard troubleshooting techniques / debugging tools and if there's a problem, we can merge and release a PR really quickly

@anujwits
Copy link

Behaviour for this is strange, this is working on some devices and not for others.
Do we need to give some permission at device level?

@mikehardy
Copy link
Collaborator

previously needed bluetooth, not supposed to need it now

@anujwits
Copy link

Yes no bluetooth permission is required. This work's for the first time.
If i update phone name, then updated name is not reflecting.

@mikehardy
Copy link
Collaborator

@anujwits then this comment drives progress on your part:

How did it go when you reached in there and added some debugging print statements + watched the logs? Is the system API we use behaving correctly? Does it mention anything in the related documentation about caching behavior in the system?

WictorWilnd added a commit to WictorWilnd/react-native-device-info that referenced this issue Feb 27, 2023
@jessenovotny
Copy link
Contributor

Does not work on iOS with v10.4.0. No matter what name our devices getDeviceName() always returns iPad. I'm not much of a iOS developer so unsure the best way to troubleshoot. Please advise

@jessenovotny
Copy link
Contributor

Turns out this is an issue with iOS 16. For anyone who winds up here, please refer to the issue documented here: #1516

wdavis122 added a commit to wdavis122/react-native-device-info that referenced this issue Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment