[TIMOB-20173] Windows: Ti.Platform.username on Windows 10
| GitHub Issue | n/a |
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-05-20T16:25:31.000+0000 |
| Affected Version/s | Release 5.1.0 |
| Fix Version/s | Release 5.4.0 |
| Components | Windows |
| Labels | qe-5.4.0 |
| Reporter | Kota Iguchi |
| Assignee | Gary Mathews |
| Created | 2015-12-23T00:15:38.000+0000 |
| Updated | 2016-06-15T19:53:01.000+0000 |
Description
On Windows 10, Ti.Platform.username always returns empty string. FYI internally we are using Windows::System::User::FindAllAsync and User::GetPropertyAsync(KnownUserProperties::AccountName) to get the accound info on Windows 10.
Attachments
PR: https://github.com/appcelerator/titanium_mobile_windows/pull/517
[~gmathews] Tested this and
Ti.Platform.usernamereturns no value. Using the demo code the label is blank, and when includingTi.API.info(Ti.Platform.username)nothing is returned to the console. Using the same code on iOS returns the correct value. Tested on: Windows 10 Pro Windows Phone 10.0 & 8.1 (Microsoft Lumia 640 LTE) Appc Studio: 4.6.0.201605030516 Ti SDK: 5.3.0.v20160509143032 Appc NPM: 4.2.5-5 Appc Core: 5.3.0-44 Node: v4.4.4Reopening Ticket.
Currently we attempt to retrieve the users
DisplayName, however, sometimes Windows cannot retrieve this information. https://social.msdn.microsoft.com/Forums/fr-FR/a5af64d0-4908-481e-9254-3ce23cc2d734/uwp-user-getpropertyasyncknownuserpropertiesdisplayname-returns-empty-string?forum=wpdevelop I have made a PR that will attempt to obtain theAccountNameorDisplayNameif either is available. If both cannot be retrieved it will fallback onto the users first and last name. It appears Windows uses the first and last name as the username if the user is signed into a Microsoft Account (_Settings > Accounts > Your email and accounts_) !windows_accounts.png|thumbnail!!windows_local.PNG|thumbnail!!windows_ms.PNG|thumbnail! master: https://github.com/appcelerator/titanium_mobile_windows/pull/708 5_3_X: https://github.com/appcelerator/titanium_mobile_windows/pull/707 *tiapp.xml Capability**Test Case*.. <windows> <Capabilities> <uap:Capability Name="userAccountInformation" /> </Capabilities> <windows> ...var win = Ti.UI.createWindow(), lbl = Ti.UI.createLabel({ text: Ti.Platform.username }); win.add(lbl); win.open();Moved this ticket to 5.4.0 as we need to discuss more on how to get the valid username.
[~gmathews] To clarify, When I ran
Ti.Platform.usernameon an iOS device, it returned the system's "name". This matches what the documentation states. (see https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Platform-property-username) In the case of a windows 10 phone,Ti.Platform.usernameshould ideally return the name found under *Settings > System > About > Device Name*master: https://github.com/appcelerator/titanium_mobile_windows/pull/708
Titanium.Platform.usernamereturns the device name. Thetiapp.xmlcapability required before is not necessary.Verified as fixed, Ti.Platform.username now returns the appropriate device name, without the need for Capabilities in the tiapp.xml. Editing the Device name and relaunching the app reflects the change correctly. Tested on: Windows 10 Pro Windows Phone 10.0 (Microsoft Lumia 640 LTE) Appc Studio: 4.6.0.201605201934 Ti SDK: 5.4.0.v20160608165242 Appc NPM: 4.2.7-2 Appc Core: 5.4.0-15 Node: v4.4.5 *Closing Ticket.*