如何使用Flurry记录iOS App中的每次点击

时间:2013-04-10 02:39:50

标签: ios flurry

如何使用Flurry记录iOS App中的每个按钮点击? 我想在我的应用程序中实现点击流。

2 个答案:

答案 0 :(得分:1)

在AppDelegate中

#import "Flurry.h"
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{     
     [Flurry startSession:@"sessionkey"];
     ...   
}

和..

-(IBAction) Click_Search:(id)sender
{     
     [Flurry logEvent:@"Seach"]; // remain logEvent 
     ...
}

答案 1 :(得分:1)

有效的方法是子类UIApplication并覆盖-sendEvent:方法  如下:

- (void)sendEvent:(UIEvent *)event {
    [super sendEvent:event];

    NSSet * allTouches = [event allTouches];
    if ([allTouches count] > 0) {
        UITouch *touch = [allTouches anyObject];
        if (touch.phase == UITouchPhaseBegan) {
             CGPoint touchLocation = [touch locationInView:touch.window];
             NSDictionary *params = @{
                 @"touch" : @{
                     @"x" : @(touchLocation.x),
                     @"y" : @(touchLocation.y)
                 }
             };
             [Flurry logEvent:@"Seach" withParameters:params];
        }
    }
}

然后,您只需要更改UIApplication中要使用的main.m类。 例如,如果您的UIApplication子类名为MyApplication,则您的主要内容将变为

int main(int argc, char *argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyApplication class]));
    }
}

<强>声明
这可能会严重影响您的应用的性能。明智地使用它。