如何判断用户是否为第一次进入app或者是第一次进入指定页面
2016-08-31 11:03
836 查看
1. 可以将版本号,或者判断第一次进入某页面的参数写在model中
#import <Foundation/Foundation.h>
@interface UserFirstLaunchModel :
NSObject
@property (copy,
nonatomic) NSString *appVersion;
@property (copy,
nonatomic) NSString *appBuild;
@property (nonatomic) BOOL isFirstLaunch;//第一次进入app
@property (nonatomic)
BOOL isHomeControllerFirstLaunch;//第一次进入首页
@property (nonatomic)
BOOL isOrderStatusControllerFirstLaunch;//第一次进入订单状态页
...
@end
2. 在app delegate中根据版本号判断是否第一次安装,取出缓存中的UserFirstLaunch对应的字典信息,与当前app比对版本号信息,如果不一致说明为第一次安装,就将app的版本号信息和首次进入的信息都初始化为YES后缓存到本地
- (void)judgeIsFirstLaunch{
NSString *appVersion = [[[NSBundle
mainBundle] infoDictionary]
objectForKey:@"CFBundleShortVersionString"];
NSString *appBuild = [[[NSBundle
mainBundle] infoDictionary]
objectForKey:@"CFBundleVersion"];
//取出缓存中的UserFirstLaunch对应的字典信息,这里我把缓存中的信息整理放到单例中管理,意思知道了就可以了
UserFirstLaunchModel *firstLaunchModel = [RMUserInfo
shareInstance].firstLaunchModel;
if ( ![firstLaunchModel.appVersion
isEqualToString:appVersion] || ![firstLaunchModel.appBuild
isEqualToString:appBuild]) {
NSDictionary *firstLaunchDict =
@{@"appVersion" : appVersion,
@"appBuild":appBuild,
@"isFirstLaunch": @YES,
@"isHomeControllerFirstLaunch":
@YES,
@"isOrderStatusControllerFirstLaunch":@YES
};
NSUserDefaults *userDefaults = [NSUserDefaults
standardUserDefaults];
[userDefaults setObject:firstLaunchDict
forKey:@"UserFirstLaunch"];
[userDefaults synchronize];
}
}
3. 比如,要求第一次安装进入首页,加一个新手指引。就可以在viewDidAppear中判断是否为第一次安装进入首页,再添加一个新手指引的方法,然后在新手指引结束后修改本地信息。
//这是使用XSportView集成的新手指引方法,但是显示效果可能没有很理想,但是思路很好,你也可以把imageview铺到视图上,点击切换图片,最后移除
- (void)showXSportView{
UserFirstLaunchModel *firstLaunchModel = [RMUserInfo
shareInstance].firstLaunchModel;
if (!firstLaunchModel.isHomeControllerFirstLaunch) {
return;
}
TXHXSportLight *SportLight = [[TXHXSportLight
alloc]init];
SportLight.messageArray =
@[
@"这是《天下货》",
@"点这里可以切换地址",
@"点这里查看消息",
];
SportLight.rectArray =
@[
[NSValue
valueWithCGRect:CGRectMake(0,
0, 0,
0)],
[NSValue
valueWithCGRect:CGRectMake(kScreenWidth /
2, 40,
50,
20)],
[NSValue
valueWithCGRect:CGRectMake(kScreenWidth -
20,
40, 40,
40)]
];
[self
presentViewController:SportLight
animated:false
completion:^{
NSMutableDictionary *firstLaunchDict = [firstLaunchModel
mj_keyValues];//这边用的是MJExtention框架,总之意思对了就可以了
[firstLaunchDict setObject:@NO
forKey:@"isHomeControllerFirstLaunch"];//修改本地首次进入首页的信息,在做缓存,下次就不会走这个方法了。
NSUserDefaults *userDefaults = [NSUserDefaults
standardUserDefaults];
[userDefaults setObject:firstLaunchDict
forKey:@"UserFirstLaunch"];
[userDefaults synchronize];
}];
}
- (void)viewDidAppear:(BOOL)animated{
[super
viewDidAppear:animated];
//设置状态栏文本颜色为白色
[[UIApplication
sharedApplication]
setStatusBarStyle:UIStatusBarStyleLightContent];
[self
showXSportView];
}
#import <Foundation/Foundation.h>
@interface UserFirstLaunchModel :
NSObject
@property (copy,
nonatomic) NSString *appVersion;
@property (copy,
nonatomic) NSString *appBuild;
@property (nonatomic) BOOL isFirstLaunch;//第一次进入app
@property (nonatomic)
BOOL isHomeControllerFirstLaunch;//第一次进入首页
@property (nonatomic)
BOOL isOrderStatusControllerFirstLaunch;//第一次进入订单状态页
...
@end
2. 在app delegate中根据版本号判断是否第一次安装,取出缓存中的UserFirstLaunch对应的字典信息,与当前app比对版本号信息,如果不一致说明为第一次安装,就将app的版本号信息和首次进入的信息都初始化为YES后缓存到本地
- (void)judgeIsFirstLaunch{
NSString *appVersion = [[[NSBundle
mainBundle] infoDictionary]
objectForKey:@"CFBundleShortVersionString"];
NSString *appBuild = [[[NSBundle
mainBundle] infoDictionary]
objectForKey:@"CFBundleVersion"];
//取出缓存中的UserFirstLaunch对应的字典信息,这里我把缓存中的信息整理放到单例中管理,意思知道了就可以了
UserFirstLaunchModel *firstLaunchModel = [RMUserInfo
shareInstance].firstLaunchModel;
if ( ![firstLaunchModel.appVersion
isEqualToString:appVersion] || ![firstLaunchModel.appBuild
isEqualToString:appBuild]) {
NSDictionary *firstLaunchDict =
@{@"appVersion" : appVersion,
@"appBuild":appBuild,
@"isFirstLaunch": @YES,
@"isHomeControllerFirstLaunch":
@YES,
@"isOrderStatusControllerFirstLaunch":@YES
};
NSUserDefaults *userDefaults = [NSUserDefaults
standardUserDefaults];
[userDefaults setObject:firstLaunchDict
forKey:@"UserFirstLaunch"];
[userDefaults synchronize];
}
}
3. 比如,要求第一次安装进入首页,加一个新手指引。就可以在viewDidAppear中判断是否为第一次安装进入首页,再添加一个新手指引的方法,然后在新手指引结束后修改本地信息。
//这是使用XSportView集成的新手指引方法,但是显示效果可能没有很理想,但是思路很好,你也可以把imageview铺到视图上,点击切换图片,最后移除
- (void)showXSportView{
UserFirstLaunchModel *firstLaunchModel = [RMUserInfo
shareInstance].firstLaunchModel;
if (!firstLaunchModel.isHomeControllerFirstLaunch) {
return;
}
TXHXSportLight *SportLight = [[TXHXSportLight
alloc]init];
SportLight.messageArray =
@[
@"这是《天下货》",
@"点这里可以切换地址",
@"点这里查看消息",
];
SportLight.rectArray =
@[
[NSValue
valueWithCGRect:CGRectMake(0,
0, 0,
0)],
[NSValue
valueWithCGRect:CGRectMake(kScreenWidth /
2, 40,
50,
20)],
[NSValue
valueWithCGRect:CGRectMake(kScreenWidth -
20,
40, 40,
40)]
];
[self
presentViewController:SportLight
animated:false
completion:^{
NSMutableDictionary *firstLaunchDict = [firstLaunchModel
mj_keyValues];//这边用的是MJExtention框架,总之意思对了就可以了
[firstLaunchDict setObject:@NO
forKey:@"isHomeControllerFirstLaunch"];//修改本地首次进入首页的信息,在做缓存,下次就不会走这个方法了。
NSUserDefaults *userDefaults = [NSUserDefaults
standardUserDefaults];
[userDefaults setObject:firstLaunchDict
forKey:@"UserFirstLaunch"];
[userDefaults synchronize];
}];
}
- (void)viewDidAppear:(BOOL)animated{
[super
viewDidAppear:animated];
//设置状态栏文本颜色为白色
[[UIApplication
sharedApplication]
setStatusBarStyle:UIStatusBarStyleLightContent];
[self
showXSportView];
}
相关文章推荐
- Android 判断用户是否第一次进入APP
- 安卓开发,点击通知栏进入指定页面及判断App是否启动
- 如何判断用户是否是第一次进入应用程序(仿微信进入动画)
- IOS添加开始导航页面(判断第一次进入app)
- 判断APP是否第一次启动,分别跳转不同页面
- JS判断用户是否有权限进入当前页面,没有直接关闭(解决IE7以上版本提示问题)
- 如何在JS中判断页面上是否存在指定控件
- php如何判断用户是从指定页面跳转进来的
- js如何判断页面中是否有指定控件~~~
- Android如何判断app是否是每日第一次登录
- 在HTML页面上点击按钮按钮携带参数flag,触发一个JS函数,经过判断是否flag==1,分别跳到两个指定的方法(或者页面)
- 判断app是否是第一次进入
- 判断是否第一次进入APP
- 如何判断是否是第一次启动app
- 判断是否第一次运行APP,以便是否进入APP介绍界面。
- android开发之splash闪屏页判断是否第一次进入app代码
- #WP7 GPS# 如何判断GPS设备可用或者用户是否开启了GPS
- iOS如何判断app是否为第一次启动
- 判断用户是否是第一次打开该app
- PHP判断用户是否已经登录(跳转到不同页面或者执行不同动作)