Skip to main content
Question

Extension attribute to see if someone is logged into imessage

  • June 22, 2023
  • 4 replies
  • 44 views

Forum|alt.badge.img+6

Hi folks,

 

Can someone help me with an EA that can collect information on if someone is logged into iMessage?

 

Thank you,

 

4 replies

howie_isaacks
Forum|alt.badge.img+23
  • Esteemed Contributor
  • June 22, 2023

I was looking for a plist file that would report this status. If someone is logged into iCloud, they would likely also be logged into iMessage too. This EA would be able to track the iCloud logged in status and display the email address used to login.

 

#!/bin/sh ## Get logged in user loggedInUser=$(stat -f%Su /dev/console icloudaccount=$( defaults read /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist Accounts | grep AccountID | cut -d '"' -f 2) if [ -z "$icloudaccount" ]; then echo "<result>No Accounts Signed In</result>" else echo "<result>$icloudaccount</result>" fi

Forum|alt.badge.img+6
  • Author
  • Contributor
  • June 28, 2023

I tried it but doesn't read if messages is logged in or not


Forum|alt.badge.img+6
  • Author
  • Contributor
  • June 28, 2023

We don't allow icloud itself, but allow folks to login to messages or facetime app. so need to see how to track those specifically


howie_isaacks
Forum|alt.badge.img+23
  • Esteemed Contributor
  • June 30, 2023

I have never used the Messages app without iCloud. I noticed that when I logged into the Messages app with an Apple ID, I saw that the plist file called "com.apple.imservice.ids.iMessage.plist" located in ~/Library/Preferences was modified. There are two keys in this plist file: ActiveAccounts and OnlineAccounts. If no one is logged in, these keys have no string after the key. This might work for you. The idea of this EA is that the value for "ActiveAccounts" will be null if the user is not logged in. I checked just now and if you log out, the stings associated with these keys disappear.

 

#!/bin/zsh currentUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'` loggedIn=$(/usr/libexec/PlistBuddy -c 'print ActiveAccounts:Array' /Users/$currentUser/Library/Preferences/com.apple.imservice.ids.iMessage.plist) if [[ -z $loggedIn ]]; then echo "<result>No</result>" else echo "<result>Yes</result>" fi

 Let me know if this works for you.