Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Fix binding for iOS Google Analytics 2 beta 3
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrisntr committed Jan 5, 2013
1 parent 61d21df commit df67423
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 35 deletions.
4 changes: 2 additions & 2 deletions GoogleAnalytics/binding/Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions GoogleAnalytics/binding/extras.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}

}
40 changes: 7 additions & 33 deletions GoogleAnalytics/binding/googleanalytics.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -31,126 +33,98 @@ interface GAI {
[Export ("sharedInstance")]
GAI SharedInstance { get; }

[Internal]
[Export ("trackerWithTrackingId:")]
GAITracker GetTracker (string trackingId);
IntPtr InternalGetTracker (string trackingId);

[Export ("dispatch")]
void Dispatch ();

}

[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 ();

Expand Down

0 comments on commit df67423

Please sign in to comment.