Posted on 06-22-2023 12:42 PM
Hi folks,
Can someone help me with an EA that can collect information on if someone is logged into iMessage?
Thank you,
Posted on 06-22-2023 02:00 PM
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
Posted on 06-28-2023 08:14 AM
I tried it but doesn't read if messages is logged in or not
Posted on 06-28-2023 08:16 AM
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
06-30-2023 07:22 AM - edited 06-30-2023 07:48 AM
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.