Get username for current logged in user

Hey,
I’m developing an app that I will release on the Mac App Store (my first one).
I need to get the username of the current logged in user.
Am I safe using this code without issues when submitting to Apple or are there better ways? :slight_smile:
Again, I’ve never put any app on MAS before and I just wanna be safe :wink:

  Dim f as FolderItem = SpecialFolder.UserHome
  Dim s as String = f.Name
  MsgBox s

Does System.EnvironmentVariable(“USER”) give you what you want??

If you’re using MBS plugins, use SystemInformationMBS.Username

Indeed it does! :wink:
Way better, thank you!

Nope, I’ll stick with your first suggestion, thanx!

Glad to help…

There is another topic here that discusses this in great length… including x-platform solutions

I’m sure there is, just couldn’t really find it :wink:

you are correct… either the topic has been removed… or the search on this forum really sucks… I entered 1/2 dozen words that I KNOW were in that topic and ZERO results.

I’m guessing this is it: here

Thank you!

I have to ask, especially as you want to be safe with MAS, why do you want the user name? Apple are funny touchy about data collection.

The user can create a project in the app and I wanted to save the user who created it within the project file. If I’m better off not to I’ll just let them enter it manually.
What do you think is the safest approach? :slight_smile:

bump
Do you guys think I should drop this feature and let the user enter their name manually to be sure if Apple doesn’t allow this? :slight_smile:

albin, I would, you never know what apple is going to do in the future…

Thank you. I was leaning towards that so I’ll skip it.
Thanks to all for helping though!

I think you’ll be okay.