您的位置:首页 > 移动开发 > IOS开发

改进iOS客户端的升级提醒功能--(by cos_sin_tan 虽然是转载的,但是我还是很有兴趣实现他的说法。)

2016-04-21 14:44 661 查看


改进iOS客户端的升级提醒功能

NOV 10TH, 2012


功能设计

先申明一下,我是码农,不是一个产品经理,但我觉得现有市面上的很多App,设计的“升级提示功能”都不太友好。在此分享一下我的想法,欢迎大家讨论。

这些App包括:新浪微博、网易微博、网易新闻客户端以及大部分带有升级提示功能的App,所以我觉得这个问题还是挺普遍的。对于该问题,一句话描述起来就是:“这些App都会在用户刚刚使用它的时候,提示有新版本,让用户去AppStore上下载最新的版本”。下面是某个应用的升级提示截图:



为什么我认为这是一个糟糕的设计呢?因为用户刚刚打开你的App,明显就是想使用你的功能。例如刚刚打开新浪微博,可能就是想看一下最新的消息或回复。刚刚打开网易新闻客户端,可能就是想看看最新的新闻。这个时候,你告诉用户有新版本,是想让用户暂时放弃使用该App吗?我不知道有多少用户会去点“升级”这个按钮,反正我每次看到这个提示都很郁闷,因为我如果点了,我就暂时不能使用该应用了(升级时原版本的App是无法使用的)。所以我在想,这个提示升级的时间能不能做得更友好一些?

有一次在地铁上我想到了一个好办法,就是让升级提示不是出现在软件刚刚打开的时候,而是用户刚刚退出App的时候,我们可以在用户刚刚退出App的时候,向iOS设备发一个本地的通知(Local
Notification),在本地通知上显示升级提示。当用户点击这个升级提示时,我们的App在启动后跳转到AppStore,这样就达到的提示升级的效果。

这样做相比以前的好处有以下几点:

用户退出App的时刻,是一个访问这个App活动的结束。在这个时候提示,用户更有理由接受升级。

即便用户当前不接受升级,但这个升级提示都会存在用户的通知中心中,用户想升级时,点击这个通知,就可以方便地一键跳到AppStore的下载页面。而之前的方法在用户取消后,用户就不方便取获下载地址了。

另外,本地通知的使用只需要iOS4.0以上版本即可,而在中国,iOS4.0以上比例达到了99%。本地通知也不需要向用户申请发送通知的DeviceToken,所以该方案很少被用户禁止(用户只能专门去通知中心将该应用的所有通知关闭)。当然,这个升级提示也不应该每次都出现,以免对用户产生太多打挠,象我在粉笔网客户端上设置的策略是最多半个月出现一次。

在我在粉笔网iPhone端实现该方案后,有一次我发现支付宝的iOS客户端也采用通知的方式来提示用户升级,看来大家都想到一块儿了。不过从通知的发送时间来看,他们应该不是使用的本地通知,而是通过服务器发送Push通知的方式。这种方式的好处是即使用户安装后一次也没有使用你的App,你还是可以通过通知来唤醒他,可能的坏处是:

可能用户已经升完级了,你还把升级通知的信息发给用户了。象我就是,支付宝都升完级了,还发通知提示我有新版可以使用。

用户如果禁止了应用的Push通知,你就没办法发送升级提醒了。


技术实现

再简单说一下技术实现,我写了一个VersionAgent类,每24小时最多向服务器请求一次最新的App版本。然后在每次App启动5秒后,检查一下是否过了24小时一次的请求阈值,如下所示:

<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">1</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">2</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">3</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">4</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">5</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">6</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">7</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">8</span>
- (void)applicationDidBecomeActive:(UIApplication *)application
{
double delayInSeconds = 5.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[[VersionAgent sharedInstance] checkVersion];
});
}

如果版本有更新,则在AppDelegate的applicationDidEnterBackgroundl回调中,发送一个本地通知,示例代码如下:

<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">1</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">2</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">3</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">4</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">5</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">6</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">7</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">8</span><span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">9</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">10</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">11</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">12</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">13</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">14</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">15</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">16</span>
- (void)applicationDidEnterBackground:(UIApplication *)application
{
if ([[VersionAgent sharedInstance] shouldShowLocalNotification]) {
dispatch_async(dispatch_get_main_queue(), ^{
UILocalNotification * localNotification = [[UILocalNotification alloc] init];
if (localNotification) {
localNotification.fireDate= [[[NSDate alloc] init] dateByAddingTimeInterval:3];
localNotification.timeZone=[NSTimeZone defaultTimeZone];
localNotification.alertBody = @"粉笔网客户端有新的版本,点击到App Store升级。";
localNotification.alertAction = @"升级";
localNotification.soundName = @"";
[application scheduleLocalNotification:localNotification];
}
});
}
}

然后通过AppDelegate的回调函数,判断App的启动方式是否是通过用户点击通知中心的升级提示来启动,如果是,则跳转到AppStore,示例代码如下:

<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">1</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">2</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">3</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">4</span>
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">5</span>
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
// open app store link
NSString * url = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@", APP_STORE_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}


题外话



最新微博上有一个新闻很火,一个技术男,给女友发弹窗通知求爱。有些人回复说这样做太麻烦,需要在服务器上记DeviceToken,否则所有用户都发的话,会让很多不相关的人收到。

其实这完全可以用本地通知来做,完全不需要服务器配合,相当简单。 具体做法是:你自己写一个发本地求爱通知的小应用,然后记下女友手机的UDID,将女友的手机设置成开发者设备,然后抓住一次机会在其手机上安装好开发者证书和你写的这个小App即可。可以把这个App隐藏在某个文件夹下面,然后打开一次,设置好本地通知的发出时间即可。

我的很多文章最后结尾都是Have fun,不过最近很难高兴起来啊。因为0x12 Big,今天google的全线产品都无法访问了。想起我每天的工作都是用google搜技术贴,用gmail收邮件,用gtalk聊天,我的联系人信息,备忘录也是同步在google contact上,我真的无法fun起来了。本博客是架设在github上的,我也很担心该博客可能也会因为是境外IP而被禁止访问。

有时候,我很气愤,而有时候,我会乐观地想,这些都是负能量的积累,黎明前的黑暗。不管怎么样,谁也无法阻止大家对自由的向往,希望有朝一日,所有人都能自由地获取信息。

Posted by 唐巧 Nov
10th, 2012  iOS

转载自 | Creative Commons BY-NC-ND 3.0

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: