友盟统计和友盟反馈的添加

来源:互联网 发布:迅雷网络加速器手机版 编辑:程序博客网 时间:2024/06/04 20:04

一 、友盟统计的添加

要在appdelegate里面导入文件

#import "MobClick.h"

//UMENG_APPKEY为你在友盟申请应用的时候得到的自己应用的appkey

- (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];

}

把这些添加之后就可以进入友盟的客户端的用户反馈信息界面,这时候登录友盟的网页信息,可以看到用户的反馈信息,当开发者在此回复的时候,客户就可以在自己的反馈界面实现弹出回复信息提示。


这样友盟的统计和反馈都添加完毕了。

}{}}


}}}}}}

}





0 1
原创粉丝点击