Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20173] Windows: Ti.Platform.username on Windows 10

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2016-05-20T16:25:31.000+0000
Affected Version/sRelease 5.1.0
Fix Version/sRelease 5.4.0
ComponentsWindows
Labelsqe-5.4.0
ReporterKota Iguchi
AssigneeGary Mathews
Created2015-12-23T00:15:38.000+0000
Updated2016-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

FileDateSize
windows_accounts.png2016-05-19T17:31:53.000+000051952
windows_local.PNG2016-05-19T21:58:04.000+00005104
windows_ms.PNG2016-05-19T21:58:04.000+00005855

Comments

  1. Gary Mathews 2016-01-03

    PR: https://github.com/appcelerator/titanium_mobile_windows/pull/517
  2. Harry Bryant 2016-05-12

    [~gmathews] Tested this and Ti.Platform.username returns no value. Using the demo code the label is blank, and when including Ti.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.4
  3. Harry Bryant 2016-05-18

    Reopening Ticket.
  4. Gary Mathews 2016-05-19

    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 the AccountName or DisplayName if 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*
       ..
       <windows>
         <Capabilities>
           <uap:Capability Name="userAccountInformation" />
         </Capabilities>
       <windows>
       ...
       
    *Test Case*
       var win = Ti.UI.createWindow(),
           lbl = Ti.UI.createLabel({ text: Ti.Platform.username });
       win.add(lbl);
       win.open();
       
  5. Kota Iguchi 2016-05-19

    Moved this ticket to 5.4.0 as we need to discuss more on how to get the valid username.
  6. Harry Bryant 2016-05-19

    [~gmathews] To clarify, When I ran Ti.Platform.username on 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.username should ideally return the name found under *Settings > System > About > Device Name*
  7. Gary Mathews 2016-05-20

    master: https://github.com/appcelerator/titanium_mobile_windows/pull/708 Titanium.Platform.username returns the device name. The tiapp.xml capability required before is not necessary.
  8. Harry Bryant 2016-06-15

    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.*

JSON Source