Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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>
Add Comment
Please, Sign In to add comment