Guest User

Untitled

a guest
May 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. // Some code -- but where does it go?
  2.  
  3. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType () {
  4. NSString *theAnchor = [[request URL] fragment];
  5. if ([theAnchor hasPrefix:@"FAPI_LogEvent"]) {
  6. NSString *textToLog = [theAnchor substringFromIndex:[@"FAPI_LogEvent" length]];
  7. [FlurryAPI logEvent:textToLog];
  8. return NO; // prevent the UIWebView from navigating to this anchor
  9. }
  10. }
  11.  
  12. // Accompanying JS
  13.  
  14. function flurryTrackEvent(text) {
  15. window.location.href = 'FAPI_LogEvent' + text;
  16. }
  17.  
  18.  
  19. //
  20. //
  21. //
  22. //
  23. //
  24.  
  25. // Here's what's in FlurryAPI.h provided by Flurry:
  26.  
  27. @interface FlurryAPI : NSObject {
  28. }
  29.  
  30. + (void)startSession:(NSString *)apiKey;
  31. + (void)logEvent:(NSString *)eventName;
  32. + (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters;
  33. + (void)logError:(NSString *)errorID message:(NSString *)message exception:(NSException *)exception;
  34.  
  35. + (void)setUserID:(NSString *)userID;
  36. + (void)setEventLoggingEnabled:(BOOL)value;
  37. + (void)setServerURL:(NSString *)url;
  38. + (void)setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose;
  39.  
  40. @end
  41.  
  42. // I'm only interested in the logEvent method.
  43. //
  44. // In Obj-C you would call this using
  45.  
  46. [FlurryAPI logEvent:@"EVENT_NAME"];
  47.  
  48. // Ideally I would want to do something like
  49.  
  50. <a onClick="flurryTrackEvent("Click_Rainbows")" href="#Rainbows">Rainbows</a>
  51. <a onClick="flurryTrackEvent("Click_Unicorns")" href="#Unicorns">Unicorns</a>
Add Comment
Please, Sign In to add comment