一 、友盟统计的添加
要在appdelegate里面导入文件
#import "MobClick.h"
- (NSString *)appKey
{
return UMENG_APPKEY;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//其他的添加内容
......
//添加友盟统计
[MobClick setDelegate:self reportPolicy:BATCH];
[MobClick setLogEnabled:YES];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
[MobClick appTerminated];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[MobClick setDelegate:self];
[MobClick appLaunched];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
[MobClick appTerminated];
}
导入#import "UMFeedback.h",以及添加代理
UMFeedbackDataDelegate
在相应的.m文件里面加入
//添加友盟反馈
[UMFeedback setLogEnabled:YES];
[UMFeedback checkWithAppkey:UMENG_APPKEY];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(umCheck:) name:UMFBCheckFinishedNotification object:nil];
在点击实现的方法里面添加
[UMFeedback showFeedback:self withAppkey:UMENG_APPKEY];
- (void)umCheck:(NSNotification *)notification {
// UIAlertView *fanKuiAlertView;
if (notification.userInfo) {
NSArray *newReplies = [notification.userInfo objectForKey:@"newReplies"];
NSLog(@"newReplies = %@", newReplies);
NSString *title = [NSString stringWithFormat:@"有%d条新回复", [newReplies count]];
NSMutableString *content = [NSMutableString string];
for (NSUInteger i = 0; i < [newReplies count]; i++) {
NSString *dateTime = [[newReplies objectAtIndex:i] objectForKey:@"datetime"];
NSString *_content = [[newReplies objectAtIndex:i] objectForKey:@"content"];
[content appendString:[NSString stringWithFormat:@"%d .......%@.......\r\n", i + 1, dateTime]];
[content appendString:_content];
[content appendString:@"\r\n\r\n"];
}
fanKuiAlertView = [[UIAlertView alloc] initWithTitle:title message:content delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"查看", nil];
if ([[UIDevice currentDevice].systemVersion floatValue] < 7.0f) {
((UILabel *) [[fanKuiAlertView subviews] objectAtIndex:1]).textAlignment = NSTextAlignmentLeft;
}
} else {
fanKuiAlertView = [[UIAlertView alloc] initWithTitle:@"没有新回复" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
}
[fanKuiAlertView show];
}
把这些添加之后就可以进入友盟的客户端的用户反馈信息界面,这时候登录友盟的网页信息,可以看到用户的反馈信息,当开发者在此回复的时候,客户就可以在自己的反馈界面实现弹出回复信息提示。
这样友盟的统计和反馈都添加完毕了。
}{}}
}}}}}}
}