From df674230081d8aea078e79c166eaf9ea09692b11 Mon Sep 17 00:00:00 2001 From: Chris Hardy Date: Sat, 5 Jan 2013 00:37:00 +0000 Subject: [PATCH] Fix binding for iOS Google Analytics 2 beta 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems that you need to handle the return of the object as a IntPtr and then create a GAITracker from that. I made the GAITracker not abstract… not too sure what the ramifications will be of this though. --- GoogleAnalytics/binding/Makefile | 4 +-- GoogleAnalytics/binding/extras.cs | 18 ++++++++++ GoogleAnalytics/binding/googleanalytics.cs | 40 ++++------------------ 3 files changed, 27 insertions(+), 35 deletions(-) mode change 100644 => 100755 GoogleAnalytics/binding/Makefile create mode 100755 GoogleAnalytics/binding/extras.cs mode change 100644 => 100755 GoogleAnalytics/binding/googleanalytics.cs diff --git a/GoogleAnalytics/binding/Makefile b/GoogleAnalytics/binding/Makefile old mode 100644 new mode 100755 index 4e7d5274..d479aace --- a/GoogleAnalytics/binding/Makefile +++ b/GoogleAnalytics/binding/Makefile @@ -24,10 +24,10 @@ GoogleAnalyticsiOS.zip: libGoogleAnalytics.a: GoogleAnalyticsiOS.zip unzip -p $< 'GoogleAnalyticsiOS_2.0beta3/Library/libGoogleAnalytics.a' > $@ -GoogleAnalytics.dll: Makefile AssemblyInfo.cs googleanalytics.cs enums.cs libGoogleAnalytics.a +GoogleAnalytics.dll: Makefile AssemblyInfo.cs googleanalytics.cs enums.cs extras.cs libGoogleAnalytics.a -mkdir -p ios $(BTOUCH) --out=$@ -e googleanalytics.cs enums.cs --sourceonly=list --tmpdir=ios - $(SMCS) $(BUILD_FLAGS) -out:$@ @list enums.cs AssemblyInfo.cs -r:monotouch.dll -res:libGoogleAnalytics.a,libGoogleAnalytics.a + $(SMCS) $(BUILD_FLAGS) -out:$@ @list enums.cs extras.cs AssemblyInfo.cs -r:monotouch.dll -res:libGoogleAnalytics.a,libGoogleAnalytics.a clean: -rm -rf list ios *.a *.dll *.o diff --git a/GoogleAnalytics/binding/extras.cs b/GoogleAnalytics/binding/extras.cs new file mode 100755 index 00000000..ae2ea67f --- /dev/null +++ b/GoogleAnalytics/binding/extras.cs @@ -0,0 +1,18 @@ +using System; + +namespace GoogleAnalytics { + + public partial class GAI + { + public GAITracker DefaultTracker { + get { + return new GAITracker (InternalDefaultTracker); + } + } + + public GAITracker GetTracker(string trackingId) { + return new GAITracker (InternalGetTracker(trackingId)); + } + } + +} \ No newline at end of file diff --git a/GoogleAnalytics/binding/googleanalytics.cs b/GoogleAnalytics/binding/googleanalytics.cs old mode 100644 new mode 100755 index 515e7312..3fe73793 --- a/GoogleAnalytics/binding/googleanalytics.cs +++ b/GoogleAnalytics/binding/googleanalytics.cs @@ -10,10 +10,12 @@ using MonoTouch.Foundation; namespace GoogleAnalytics { + [BaseType (typeof (NSObject))] interface GAI { + [Internal] [Export ("defaultTracker")] - GAITracker DefaultTracker { get; set; } + IntPtr InternalDefaultTracker { get; set; } [Export ("debug")] bool Debug { get; set; } @@ -31,8 +33,9 @@ interface GAI { [Export ("sharedInstance")] GAI SharedInstance { get; } + [Internal] [Export ("trackerWithTrackingId:")] - GAITracker GetTracker (string trackingId); + IntPtr InternalGetTracker (string trackingId); [Export ("dispatch")] void Dispatch (); @@ -40,117 +43,88 @@ interface GAI { } [BaseType (typeof (NSObject))] - [Model] interface GAITracker { - [Abstract] [Export ("trackingId")] string TrackingId { get; } - - [Abstract] + [Export ("appName")] string AppName { get; set; } - [Abstract] [Export ("appId")] string AppId { get; set; } - [Abstract] [Export ("appVersion")] string AppVersion { get; set; } - [Abstract] [Export ("anonymize")] bool Anonymize { get; set; } - - [Abstract] + [Export ("useHttps")] bool UseHttps { get; set; } - [Abstract] [Export ("sampleRate")] double SampleRate { get; set; } - [Abstract] [Export ("clientId")] string ClientId { get; } - [Abstract] [Export ("appScreen")] string AppScreen { get; set; } - [Abstract] [Export ("referrerUrl")] string ReferrerUrl { get; set; } - [Abstract] [Export ("campaignUrl")] string CampaignUrl { get; set; } - [Abstract] [Export ("sessionStart")] bool SessionStart { get; set; } - [Abstract] [Export ("sessionTimeout")] double SessionTimeout { get; set; } - [Abstract] [Export ("trackView")] bool TrackView (); - [Abstract] [Export ("trackView:")] bool TrackView (string screen); - [Abstract] [Export ("trackEventWithCategory:withAction:withLabel:withValue:")] bool TrackEvent(string category, string action, string label, NSNumber value); - [Abstract] [Export ("trackTransaction:")] bool TrackTransaction (GAITransaction transaction); - [Abstract] [Export ("trackException:withDescription:")] bool TrackException (bool isFatal, string format ); - [Abstract] [Export ("trackException:withNSException:")] bool TrackException (bool isFatal, NSException exception); - [Abstract] [Export ("trackException:withNSError:")] bool TrackException (bool isFatal, NSError error); - [Abstract] [Export ("trackTimingWithCategory:withValue:withName:withLabel:")] bool TrackTiming (string category, double time, string name, string label); - [Abstract] [Export ("trackSocial:withAction:withTarget:")] bool TrackSocial (string network, string action, string target); - [Abstract] [Export ("set:value:")] bool Setvalue (string parameterName, string value); - [Abstract] [Export ("get:")] string Get (string parameterName); - [Abstract] [Export ("send:params:")] bool Sendparams (string trackType, NSDictionary parameters); - [Abstract] [Export ("setCustom:dimension:")] bool SetCustom (int index, string dimension); - [Abstract] [Export ("setCustom:metric:")] bool SetCustom (int index, NSNumber metric); - [Abstract] [Export ("close")] void Close ();