Created
April 28, 2010 17:42
-
-
Save anonymous/382433 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some code -- but where does it go? | |
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType () { | |
NSString *theAnchor = [[request URL] fragment]; | |
if ([theAnchor hasPrefix:@"FAPI_LogEvent"]) { | |
NSString *textToLog = [theAnchor substringFromIndex:[@"FAPI_LogEvent" length]]; | |
[FlurryAPI logEvent:textToLog]; | |
return NO; // prevent the UIWebView from navigating to this anchor | |
} | |
} | |
// Accompanying JS | |
function flurryTrackEvent(text) { | |
window.location.href = 'FAPI_LogEvent' + text; | |
} | |
// | |
// | |
// | |
// | |
// | |
// Here's what's in FlurryAPI.h provided by Flurry: | |
@interface FlurryAPI : NSObject { | |
} | |
+ (void)startSession:(NSString *)apiKey; | |
+ (void)logEvent:(NSString *)eventName; | |
+ (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters; | |
+ (void)logError:(NSString *)errorID message:(NSString *)message exception:(NSException *)exception; | |
+ (void)setUserID:(NSString *)userID; | |
+ (void)setEventLoggingEnabled:(BOOL)value; | |
+ (void)setServerURL:(NSString *)url; | |
+ (void)setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose; | |
@end | |
// I'm only interested in the logEvent method. | |
// | |
// In Obj-C you would call this using | |
[FlurryAPI logEvent:@"EVENT_NAME"]; | |
// Ideally I would want to do something like | |
<a onClick="flurryTrackEvent("Click_Rainbows")" href="#Rainbows">Rainbows</a> | |
<a onClick="flurryTrackEvent("Click_Unicorns")" href="#Unicorns">Unicorns</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment