get current workspace(spaces) id

Is there a way to get the current workspace (i.e spaces) id on OSX? The only ways I know of are either deprecated (CGWindowWorkSpace) or part of a private API (CGSWindows) and therefore would probably get rejected by the Mac App Store.

I have the MBS plugins so if there is something in there that would be great, but I have not been able to find anything.

Thanks,

Phil

In case anyone is interested, I found a solution for this. It does require the MBS plugins.

Public Function getActiveSpaceID(dictWindows() as dictionary = nil) as string
  If dictWindows = Nil Then 
    dictWindows = CGWindowMBS.GetWindowListInfo( CGWindowMBS.kCGWindowListOptionOnScreenOnly, CGWindowMBS.kCGNullWindowID )
  End
  Dim oDefaults As NSUserDefaultsMBS = NSUserDefaultsMBS.standardUserDefaults
  oDefaults.removeSuiteNamed( "com.apple.spaces" )
  oDefaults.addSuiteNamed( "com.apple.spaces" )
  
  Dim dictSpaceProps As Dictionary
  Dim aroSpaces( -1 ) As Variant
  Dim iSpaceCount As Integer
  Dim iWindowCount As Integer = dictWindows.ubound
  
  dictSpaceProps = oDefaults.dictionaryForKey( "SpacesDisplayConfiguration" )
  aroSpaces = dictSpaceProps.value( "Space Properties" )
  iSpaceCount = aroSpaces.ubound
  Dim sSpaceID As String
  
  For i As Integer = 0 To iWindowCount
    Dim d As Dictionary = dictWindows( i )
    Dim iWindowID As Integer = d.value( CGWindowMBS.kCGWindowNumber ).integervalue
    system.DebugLog "window id: " + str( iWindowID )
    Dim dictSpaces As New Dictionary

    For cnt As Integer = 0 To iSpaceCount
      Dim oWindowDictionary As Dictionary = aroSpaces( cnt )
      Dim aroWindowIDs( -1 ) As Variant
      aroWindowIDs = oWindowDictionary.value( "windows" )
      sSpaceID = oWindowDictionary.value( "name" ).StringValue
      For idx As Integer = 0 To ubound( aroWindowIDs )
        If aroWindowIDs( idx ).IntegerValue = iWindowID Then
          dictSpaces.value( sSpaceID ) = iWindowID
        End
      Next
    Next
    If dictSpaces.Count = 1 Then 
      Dim v() As Variant
      v = dictSpaces.keys
      Return v( 0 ).StringValue
    End
  Next
  
  
End Function