我最近使用Make My Trip应用。每当我启动应用程序时,我都会发现一个非常有吸引力的应用更新弹出屏幕。它说要更新应用程序。我想在我的应用更新中加入它。请告诉我怎么做。 我附上一张截图供您考虑。
I was recently using "Make My Trip" app. I found a very attractive app update pop up screen appearing whenever I launch the app. It says to update the app. I want to incorporate that in my app update too. Please tell me how can I do it. I am attaching a screenshot here for your consideration.
推荐答案
您可以从 iTunes商店查找API : itunes.apple/lookup?bundleId=YOUR_BUNDLE_ID ,在此您可以在App Store上获得App版本。
You can get all App info from iTunes store lookup API: itunes.apple/lookup?bundleId=YOUR_BUNDLE_ID, in this you can get App version on App Store.
制作您的设计屏幕,以便向App用户展示,然后在App Store和App上比较您的App版本。用户的设备,如果两个版本不相等,则显示更新版本屏幕。
Make your design screen as you want to show your App users, Then compare your App version on App store & user's device, if both version not equal then show the update version screen.
以下是在App Store和App上比较应用版本的完整实现。设备:
Below is the complete implementation to compare app version on App store & device:
func isUpdateAvailableOnStore() -> Bool { let infoDictionary = Bundle.main.infoDictionary let bundleId = infoDictionary!["CFBundleIdentifier"] as! String let url = URL(string: "itunes.apple/lookup?bundleId=\(bundleId)") let infoData = try? Data(contentsOf: url!) let appInfo = (try? JSONSerialization.jsonObject(with: infoData! , options: [])) as? [String: Any] if let resultCount = appInfo!["resultCount"] as? Int, resultCount == 1 { if let results = appInfo!["results"] as? [[String:Any]] { if let appStoreVersion = results[0]["version"] as? String{ let currentAppVersion = infoDictionary!["CFBundleShortVersionString"] as? String if !(appStoreVersion == currentAppVersion) { return true } } } } return false }在你的 func应用程序中调用此函数(_ application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:Any]?) - > Bool 的功能AppDelegate 。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Your code here if self.isUpdateAvailableOnStore(){ // SHOW YOUR UPDATE SCREEN TO USER'S }else{ // APP VERSION IS UPDATED ON DEVICE } return true }更多推荐
如何以迷人的屏幕形式向用户提供应用更新?
发布评论