iOS应用程序更新问题

iOS应用程序更新问题,ios,Ios,我可以在应用程序设置界面中添加“检查更新”按钮,然后提交到apple store吗。它会被拒绝吗?如果我无法添加按钮来检查更新,是否有其他方法来检测是否有新的应用程序更新?是。您可以添加以检查更新是否可用。您还可以知道更新是否可用。首先,您需要从info.plist文件中获取当前的应用程序版本号。稍后,您必须从apple itunes获取版本号。现在比较两个更新,如果appstore版本大于当前版本,则显示一个弹出窗口,说明新更新可用。当用户每次启动应用程序时,或者根据您的需求从任何地方启动应用

我可以在应用程序设置界面中添加“检查更新”按钮,然后提交到apple store吗。它会被拒绝吗?如果我无法添加按钮来检查更新,是否有其他方法来检测是否有新的应用程序更新?

是。您可以添加以检查更新是否可用。您还可以知道更新是否可用。首先,您需要从info.plist文件中获取当前的应用程序版本号。稍后,您必须从apple itunes获取版本号。现在比较两个更新,如果appstore版本大于当前版本,则显示一个弹出窗口,说明新更新可用。当用户每次启动应用程序时,或者根据您的需求从任何地方启动应用程序时,您都可以通过AppDelegate来完成这一切

以下是如何获取版本号:

Swift版本

  func appUpdateAvailable(storeInfoURL: String) -> Bool
    {
        var upgradeAvailable = false

        // Get the main bundle of the app so that we can determine the app's version number
        let bundle = NSBundle.mainBundle()
        if let infoDictionary = bundle.infoDictionary {
            // The URL for this app on the iTunes store uses the Apple ID for the  This never changes, so it is a constant
            let urlOnAppStore = NSURL(string: storeInfoURL)
            if let dataInJSON = NSData(contentsOfURL: urlOnAppStore!) {
                // Try to deserialize the JSON that we got
                if let lookupResults = try? NSJSONSerialization.JSONObjectWithData(dataInJSON, options: NSJSONReadingOptions()) {
                    // Determine how many results we got. There should be exactly one, but will be zero if the URL was wrong
                    if let resultCount = lookupResults["resultCount"] as? Int {
                        if resultCount == 1 {
                            // Get the version number of the version in the App Store
                            if let appStoreVersion = lookupResults["results"]!![0]["version"] as? String {
                                // Get the version number of the current version
                                if let currentVersion = infoDictionary["CFBundleShortVersionString"] as? String {
                                    // Check if they are the same. If not, an upgrade is available.
                                    if appStoreVersion != currentVersion {
                                        upgradeAvailable = true                      
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        return upgradeAvailable
    }
目标-C

 -(BOOL) needsUpdate{
    NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString* appID = infoDictionary[@"CFBundleIdentifier"];
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", appID]];
    NSData* data = [NSData dataWithContentsOfURL:url];
    NSDictionary* lookup = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

    if ([lookup[@"resultCount"] integerValue] == 1){
        NSString* appStoreVersion = lookup[@"results"][0][@"version"];
        NSString* currentVersion = infoDictionary[@"CFBundleShortVersionString"];
        if (![appStoreVersion isEqualToString:currentVersion]){
            NSLog(@"Need to update [%@ != %@]", appStoreVersion, currentVersion);
            return YES;
            }
        }
        return NO;
    }

为此,您需要一个推送服务器,只需在您的应用程序更新时向所有用户发送推送消息,告知他们要更新到最新版本即可。当应用程序可升级时,iOS应用商店应用程序已显示徽章。许多用户甚至将设备设置为自动更新应用程序。这样做有意义吗?很高兴收到你的回答,你的回答给了我很大的帮助,谢谢!