iOS Question Get App Store Version

mmieher

Active Member
Licensed User
Longtime User
Finally got my App approved in the App Store. Good grief. I thought Apple was supposed to be "easier".

Is there a way to get the version number form the App Store?

Similar to this in B4A?

B4X:
        SendVersionRequest("com.spothops.com")
        PgmVer = PM.GetVersionName("com.spothops.com")

Marc
 

marcick

Well-Known Member
Licensed User
Longtime User
Not sure but seems to me not.
Anyway I use a string variable for it, like

Public MyAppVersion As String="1.2.0 build 007"
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,

you can use the Lookup Api:

B4X:
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

Jan
 
Upvote 0
Top