有人知道如何检测用户是否已经取消了“In App”尝试安装其他App版本 [英] Does anyone know how to detect if a user has cancelled an "In App" attempt to install another App version

查看:183
本文介绍了有人知道如何检测用户是否已经取消了“In App”尝试安装其他App版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用企业开发计划推出一个内部IOS应用程序。我在一个阶段,我有一个VC,允许用户触摸一个按钮,从应用程序内部下载并安装升级。



它工作得很好。然而,如果网络有点慢,IOS提示的信息被抛出在用户你想安装,等等......出现了一点点。所以,用户按下安装按钮后,我禁用它。但是,如果用户触摸,取消,当IOS提示时,我不知道如何检测到这个。



我正在使用Xcode 4.5和IOS6.0几个设备iPhone 3,4和5。



没有给整个链接,下载的代码如下。

   - (void)actionSheet:(UIActionSheet *)modalView clickedButtonAtIndex:(NSInteger)buttonIndex {

if(buttonIndex == 0){

[self.IBOInstallActivityInd startAnimating];
[self enableInstallButton:NO];
self.tabBarController.tabBar.userInteractionEnabled = NO;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:APP_INSTALL_FROM]];

}

} // actionSheet:clickedButtonAtIndex

而且,正如我所说,是好的 - 它的作品。但是如果用户触摸取消提示,我想能够告诉。正如你所看到的,我锁定用户界面。您可能会问为什么,如果应用程序即将关闭并接收升级。



嗯,根据网络速度,我想证明用户不止一次地按下按钮。但是,如果用户取消,我想要在一个位置,我可以重新启动用户界面,启用标签栏等...



我已经爬网没发现!而且,我猜这个苹果网站上的答案是可能的。但是,这需要很多阅读。



有没有人有任何想法?

解决方案

我不知道如何捕获取消动作,但我可以告诉你我们如何处理这种情况。 p>

我们编译的每个构建都具有内置的特定修订版本,我们还将其嵌入到服务器上的plist文件中。我们的应用程序比较两个版本号,以确定是否有可用的更新(版本不匹配,这也允许我们回滚)。



在您的情况下,你可以做的只是让VC每隔X秒验证服务器,并刷新状态。如果他们升级,他们将从应用程序启动,如果没有,刷新将使该按钮再次启用。



更简单的解决方案:只在导航到VC时运行此查询。所以如果他们取消他们将不得不退出VC并重新进入。



这是解释plist文件看起来像我们:

  NSString * localCopyPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)lastObject]; 
localCopyPath = [localCopyPath stringByAppendingPathComponent:@MDM_SERVER.plist];
NSFileManager * fileManager = [[NSFileManager alloc] init];

BOOL created = [fileManager createFileAtPath:localCopyPath contents:plistData attributes:nil];
if(created){
NSDictionary * fullDict = [NSDictionary dictionaryWithContentsOfFile:localCopyPath];
if(fullDict){
NSArray * a = [fullDict objectForKey:@items];
NSDictionary * mdmDict = [a objectAtIndex:0];
NSDictionary * metaDict = [mdmDict objectForKey:@metadata];

//格式为1.0.1779的字符串
NSString * serverFullVersion = [metaDict objectForKey:@bundle-version];

//我们将始终比较最后一位数
NSUInteger lastPeriod = [serverFullVersion rangeOfString:@。选项:NSBackwardsSearch] .location;
if(NSNotFound!= lastPeriod&& [serverFullVersion length]> lastPeriod){
//更新我们找到答案的时间
mdmCheckedAt = [NSDate date];
NSString * serverSvnRevision = [serverFullVersion substringFromIndex:(lastPeriod + 1)];
//大测试 - 如果我们自己的svn版本是不同的,然后加载
// URL来告诉iOS升级自己
if(![kRevisionNumber isEqualToString:serverSvnRevision]){
//您的代码HERE


I'm rolling out an In-House IOS App using the Enterprise development program. I'm at a stage where I have a VC that allows the user to touch a button that downloads and installs the upgrade from inside the App.

It works well. However, if the network's a little slow, the IOS prompted message thats thrown at the user "Would you like to install, such and such..." appears a little late. So, after the user has pressed the "Install" button, I disable it. However, if there user touches, "Cancel" when prompted by IOS, I do not know how to detect this.

I'm using Xcode 4.5 and IOS6.0 on several devices iPhone 3, 4 and 5.

Without giving the entire link away, the code that does the download is as follows.

- (void)actionSheet:(UIActionSheet *)modalView clickedButtonAtIndex:(NSInteger)buttonIndex {

if (buttonIndex == 0) {

    [self.IBOInstallActivityInd startAnimating];
    [self enableInstallButton:NO];
    self.tabBarController.tabBar.userInteractionEnabled = NO;
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:APP_INSTALL_FROM]];

    }

} // actionSheet:clickedButtonAtIndex

And, as I've said, is good - it works. But if the user touches "Cancel" to the prompt, I want to be able to tell. As you can see, I'm locking the user interface down. you might ask why, if an App is about to close and receive its upgrade.

Well, depending on network speed, I want to proven the user from hitting the button more than once. But, if the user cancels, I want to be in a position where I can reinitiate the user interface, enable tab bar etc...

I've crawled the Web, found nothing! And, I guess the answer is probs on the Apple site, as good as it is. But, it takes a damned lot of reading.

Has anyone got any ideas at all?

解决方案

I don't know how to capture the cancel action, but I can tell you how we handle this situation.

Every build that we compile has a specific revision built into it, which we also embed in the plist file on our server. Our app compares the two version numbers to determine whether or not an update is available (versions don't match, which allows us to rollback too).

In your case, what you could do is simply have that VC verify the server every X seconds and refresh the state. If they take the upgrade, they'll be booted from the app, and if they don't then the refresh will make the button enabled again.

Simpler solution: Only run this query when they navigate to the VC. So if they cancel they'll have to exit the VC and reenter.

Here's what parsing the plist file looks like for us:

            NSString *localCopyPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
            localCopyPath = [localCopyPath stringByAppendingPathComponent:@"MDM_SERVER.plist"];
            NSFileManager *fileManager = [[NSFileManager alloc] init];

            BOOL created = [fileManager createFileAtPath:localCopyPath contents:plistData attributes:nil];                
            if (created) {
                NSDictionary *fullDict = [NSDictionary dictionaryWithContentsOfFile:localCopyPath];
                if (fullDict) {
                    NSArray *a = [fullDict objectForKey:@"items"];
                    NSDictionary *mdmDict = [a objectAtIndex:0];
                    NSDictionary *metaDict = [mdmDict objectForKey:@"metadata"];

                    // String of format "1.0.1779"
                    NSString *serverFullVersion = [metaDict objectForKey:@"bundle-version"];

                    // We will always compare on the last digit
                    NSUInteger lastPeriod = [serverFullVersion rangeOfString:@"." options:NSBackwardsSearch].location;
                    if (NSNotFound != lastPeriod && [serverFullVersion length] > lastPeriod) {
                        // update the time when we found an answer
                        mdmCheckedAt = [NSDate date];
                        NSString *serverSvnRevision = [serverFullVersion substringFromIndex:(lastPeriod + 1)];
                        // the big test - if our own svn version is different, then load the 
                        // URL to tell iOS to upgrade ourself
                        if (![kRevisionNumber isEqualToString:serverSvnRevision]) {
// Your Code HERE

这篇关于有人知道如何检测用户是否已经取消了“In App”尝试安装其他App版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆