1
有沒有在xamarin.ios或xamarin.android或mvvmcross5檢查appstore中的應用版本號的方法嗎?檢查appstore應用版本xmarin(強制升級應用)
有人可以請我重定向到一個樣本?
有沒有在xamarin.ios或xamarin.android或mvvmcross5檢查appstore中的應用版本號的方法嗎?檢查appstore應用版本xmarin(強制升級應用)
有人可以請我重定向到一個樣本?
在這裏,你去。我找到了一個解決方案:
private string GetAppStoreAppVersion()
{
string appStoreAppVersion = string.Empty;
try
{
var dictionary = NSBundle.MainBundle.InfoDictionary;
string applicationID = dictionary[@"CFBundleIdentifier"].ToString();
NSUrl url = new NSUrl($"http://itunes.apple.com/lookup?bundleId={applicationID}");
NSData data = NSData.FromUrl(url);
NSError error = new NSError();
NSDictionary lookup = NSJsonSerialization.Deserialize(data, 0, out error) as NSDictionary;
if (error == null
&& lookup != null
&& lookup.Keys.Length >= 1
&& lookup["resultCount"] != null
&& Convert.ToInt32(lookup["resultCount"].ToString()) > 0)
{
var results = lookup[@"results"] as NSArray;
if (results != null && results.Count > 0)
{
appStoreAppVersion = results.GetItem<NSDictionary>(0)["version"].ToString();
}
}
}
catch (Exception ex)
{
//No need to throw an exception if version check fails
}
return appStoreAppVersion;
}
如果你正在尋找在後端實現這個,那麼這裏是獲取它的代碼。
string url = "http://itunes.apple.com/lookup?bundleId=yourbundleid";
using (var webClient = new System.Net.WebClient())
{
string jsonString = webClient.DownloadString(string.Format(url));
var lookup = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);
if (lookup != null
&& lookup.Count >= 1
&& lookup["resultCount"] != null
&& Convert.ToInt32(lookup["resultCount"].ToString()) > 0)
{
var results = JsonConvert.DeserializeObject<List<object>>(lookup[@"results"].ToString());
if (results != null && results.Count > 0)
{
var values = JsonConvert.DeserializeObject<Dictionary<string, object>>(results[0].ToString());
appStoreAppVersion = values.ContainsKey("version") ? values["version"].ToString() : string.Empty;
}
}
}
return appStoreAppVersion;
可能重複[檢查我的應用程序是否在AppStore上有新版本](https://stackoverflow.com/questions/6256748/check-if-my-app-has-a-new-version-上的appstore) – Jason