HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 以编程方式点击HTML href以更新应用程序大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在为具有临时分发的企业应用程序进行更新计划.

对于更新,Apple建议让用户访问HTML页面并点击链接

href="itms-services://?action=download-manifest&url=http://example.com/
manifest.plist"

http://help.apple.com/iosdeployment-apps/#app43ad871e

我不想这样做.我希望应用程序以编程方式检查启动时的更新,并使用UIAlertView提醒用户可以获得更新.

这是我到目前为止在应用中所做的事.FinishLaunching.复杂的plist解析来自这里找到的示例plist的结构:http://help.apple.com/iosdeployment-apps/#app43ad78b3

NSLog(@"checking for update");
NSData *plistData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://example.com/MyApp.plist"]];
if (plistData) {
    NSLog(@"finished checking for update");
    NSError *error;
    NSPropertyListFormat format;
    NSDictionary *plist = [NSPropertyListserialization propertyListWithData:plistData options:NSPropertyListImmutable format:&format error:&error];
    if (plist) {
        NSArray *items = [plist valueForKey:@"items"];
        NSDictionary *Dictionary;
        if ([items count] > 0) {
            Dictionary = [items objectATindex:0];
        }
        NSDictionary *MetaData = [Dictionary objectForKey:@"Metadata"];

        float currentVersion = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundLeversion"] floatValue];
        float newVersion = [[MetaData objectForKey:@"bundle-version"] floatValue];
        NSLog(@"newVersion: %f,currentVersion: %f",newVersion,currentVersion);
        if (newVersion > currentVersion) {
            NSLog(@"A new update is available");
            UIAlertView *alert = [[UIAlertView alloc] initWithtitle:@"update available" message:@"A new update is available." delegate:self cancelButtontitle:@"Cancel" otherButtontitles:@"updatE",nil];
            [alert show];
        }       
    }
}

然后我有我的UIAlertView委托方法

- (void)alertView:(UIAlertView *)alertView clickedButtonATindex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
        NSLog(@"downloading full update");
        UIWebView *webView = [[UIWebView alloc] init];
        [webView loadrequest:[[NSURLrequest alloc] initWithURL:[NSURL URLWithString:@"itms-services://?action=download-manifest&url=http://example.com/MyApp.plist"] cachePolicy:NSURLrequestuseProtocolCachePolicy timeoutInterval:10.0]];
    }
}

一些东西:

>我知道[alert show]不应该在应用程序didFinish中调用,但我稍后会更改它.
>我不知道下载plistData的速度有多快以及下载如何影响应用程序.
>更重要的是,我的警报视图委托方法不起作用,并且不下载更新.即使我使用@property(非原子,强)UIWebView * webView引入webView,该方法也不会做任何事情.
>我认为DropBox已正确配置MIME,因为我可以通过谷歌Chrome下载.ipa.

所以我真正需要的是使用NSURLConnection(NSURLrequest等)来复制用户点击HTML href的行为.之后,我认为将进行全面更新.

解决方法

您可以使用自动打开URL

[[UIApplication sharedApplication] openURL:...];

我不知道它是否适用于itms-services:urls,但它适用于其他定制的URL方案,如tel:,fb:等,所以它应该做,除非Apple特别阻止它.

大佬总结

以上是大佬教程为你收集整理的iphone – 以编程方式点击HTML href以更新应用程序全部内容,希望文章能够帮你解决iphone – 以编程方式点击HTML href以更新应用程序所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。