Log("AppStore Version: " & AppStoreVersion)
Sub AppStoreVersion As String
Dim NaObj As NativeObject
Dim Result() As Byte = NaObj.NSDataToArray(NaObj.Initialize("NSData").RunMethod("dataWithContentsOfURL:",Array(GetUrl)))
Dim JSONString As String = BytesToString(Result,0,Result.Length,"UTF-8")
Dim Parser As JSONParser
Parser.Initialize(JSONString)
Dim l As List = Parser.NextObject.Get("results")
Dim m As Map = l.Get(0)
Dim Version As String = m.Get("version")
Return Version
End Sub
Private Sub GetUrl As Object
Dim NaObj As NativeObject = Me
Dim CountryCode As String = NaObj.RunMethod("getCountryCode", Null).AsString
Dim BundleID As String = NaObj.Initialize("NSBundle").RunMethod("mainBundle",Null).RunMethod("infoDictionary",Array()).RunMethod("objectForKey:",Array("CFBundleIdentifier")).AsString
Dim Url As String
Url = $"http://itunes.apple.com/${CountryCode}/lookup?bundleId=${BundleID}"$
Dim NaObj As NativeObject
NaObj = NaObj.Initialize("NSURL").RunMethod("URLWithString:",Array(Url))
Return NaObj
#If OBJC
- (NSString*) getCountryCode {
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
return countryCode;
}
#end if
End Sub