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

Commit

Permalink
Fixed the google analytics binding. Added a sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clancey committed Feb 10, 2012
1 parent 2be355d commit 903646f
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 26 deletions.
Binary file modified GoogleAdMobAds/binding/GoogleAdMobAds.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion GoogleAnalytics/binding/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using MonoTouch.ObjCRuntime;

[assembly: LinkWith ("libFixedGoogleAnalytics.a", LinkTarget.Simulator | LinkTarget.ArmV6 | LinkTarget.ArmV7, "-lsqlite3.0", Frameworks = "CFNetwork", ForceLoad = true)]
[assembly: LinkWith ("libGoogleAnalytics.a", LinkTarget.Simulator | LinkTarget.ArmV6 | LinkTarget.ArmV7, "-lsqlite3.0", Frameworks = "CFNetwork", ForceLoad = true)]
Binary file added GoogleAnalytics/binding/GoogleAnalytics.dll
Binary file not shown.
23 changes: 4 additions & 19 deletions GoogleAnalytics/binding/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#
# This makefile is worse than it should be because Google shipped a broken
# libGoogleAnalytics_Nothub.a, we build a stub class to satisfy the unused
# dependency.
#

BUILD_FLAGS=-unsafe -target:library -nowarn:436 -nowarn:219
BTOUCH=/Developer/MonoTouch/usr/bin/btouch
Expand All @@ -26,23 +21,13 @@ GoogleAnalyticsiOS_1.4.tar.gz:
# clang -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -fobjc-abi-version=2 -fobjc-legacy-dispatch -c -arch i386 stub.m -o i386.o


libFixedGoogleAnalytics.a: libGoogleAnalytics_NoThumb.a $(STUBS)
cp libGoogleAnalytics_NoThumb.a libFixedGoogleAnalytics.a
# lipo libGoogleAnalytics_NoThumb.a -thin armv6 -output libarmv6.a
# ar -q libarmv6.a armv6.o
# lipo libGoogleAnalytics_NoThumb.a -thin armv7 -output libarmv7.a
# ar -q libarmv7.a armv7.o
# lipo libGoogleAnalytics_NoThumb.a -thin i386 -output libi386.a
# ar -q libi386.a i386.o
# lipo -create libarmv6.a libarmv7.a libi386.a -output libFixedGoogleAnalytics.a

libGoogleAnalytics_NoThumb.a: GoogleAnalyticsiOS_1.4.tar.gz
tar xOzvf GoogleAnalyticsiOS_1.4.tar.gz 'Google Analytics SDK/Library/libGoogleAnalytics_NoThumb.a' > $@
libGoogleAnalytics.a: GoogleAnalyticsiOS_1.4.tar.gz
tar xOzvf GoogleAnalyticsiOS_1.4.tar.gz 'Google Analytics SDK/Library/libGoogleAnalytics.a' > $@

GoogleAnalytics.dll: Makefile AssemblyInfo.cs googleanalytics.cs enums.cs libFixedGoogleAnalytics.a
GoogleAnalytics.dll: Makefile AssemblyInfo.cs googleanalytics.cs enums.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:libFixedGoogleAnalytics.a,libFixedGoogleAnalytics.a
$(SMCS) $(BUILD_FLAGS) -out:$@ @list enums.cs AssemblyInfo.cs -r:monotouch.dll -res:libGoogleAnalytics.a,libGoogleAnalytics.a

clean:
-rm -rf list ios *.a *.dll *.o
8 changes: 4 additions & 4 deletions GoogleAnalytics/binding/googleanalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ interface GANTracker {
void StopTracker ();

// Not supported until Google fixes their library
//[Export ("trackPageview:withError:")]
//bool TrackPageView (string pageUrl, out NSError nsError);
[Export ("trackPageview:withError:")]
bool TrackPageView (string pageUrl, out NSError nsError);

[Export ("trackEvent:action:label:value:withError:")]
bool TrackEvent (string category, string action, string label, int value, out NSError nsError);

[Export ("setCustomVariableAtIndex:name:value:scope:withError")]
[Export ("setCustomVariableAtIndex:name:value:scope:withError:")]
bool SetCustomVariable (int index, string name, string value, GanCVScope scope, out NSError nsError);

[Export ("setCustomVariableAtIndex:name:value:withError")]
[Export ("setCustomVariableAtIndex:name:value:withError:")]
bool SetCustomVariable (int index, string name, string value, out NSError nsError);

[Export ("addTransaction:totalPrice:storeName:totalTax:shippingCost:withError:")]
Expand Down
67 changes: 67 additions & 0 deletions GoogleAnalytics/sample/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// This shows the various capabilities of the
// AtmHud library
//
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Drawing;
using MonoTouch.Dialog;

namespace sample
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
const string account = "UA-27277921-1";
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
GoogleAnalytics.GANTracker.SharedTracker.StartTracker(account,60,null);
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController = new DialogViewController(CreateRoot());
window.MakeKeyAndVisible ();

return true;
}

static void Main (string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main (args, null, "AppDelegate");
}
public RootElement CreateRoot()
{
return new RootElement("Google Analytics")
{
new Section()
{
new StringElement("Track Event",delegate{
NSError error;
var success = GoogleAnalytics.GANTracker.SharedTracker.TrackEvent("Sample Data","Button Clicked","Xamarin!",1,out error);
Console.WriteLine(error);
ShowMessage(success ? "Success" : "Error",error == null ? "" : error.ToString());
}),
new StringElement("Track Page",delegate{
NSError error;
var success = GoogleAnalytics.GANTracker.SharedTracker.TrackPageView("HomePage",out error);
Console.WriteLine(error);
ShowMessage(success ? "Success" : "Error",error == null ? "" : error.ToString());
}),
new StringElement("Set Custom Variable",delegate{
NSError error;
var success = GoogleAnalytics.GANTracker.SharedTracker.SetCustomVariable(0,"Version",UIDevice.CurrentDevice.SystemVersion,out error);
Console.WriteLine(error);
ShowMessage(success ? "Success" : "Error",error == null ? "" : error.ToString());
}),
}
};
}
public void ShowMessage(string title,string message)
{
var alert = new UIAlertView(title,message,null,"OK");
alert.Show();
}
}
}
16 changes: 16 additions & 0 deletions GoogleAnalytics/sample/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
75 changes: 75 additions & 0 deletions GoogleAnalytics/sample/sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>sample</RootNamespace>
<AssemblyName>sample</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchDebug>true</MtouchDebug>
<MtouchProfiling>true</MtouchProfiling>
<MtouchLink>None</MtouchLink>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchLink>None</MtouchLink>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<MtouchProfiling>true</MtouchProfiling>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="GoogleAnalytics">
<HintPath>..\binaries\GoogleAnalytics.dll</HintPath>
</Reference>
<Reference Include="MonoTouch.Dialog-1" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppDelegate.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
Binary file added GoogleAnalytics/sample/sample.pidb
Binary file not shown.
26 changes: 26 additions & 0 deletions GoogleAnalytics/sample/sample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sample", "sample.csproj", "{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Debug|iPhone.ActiveCfg = Debug|iPhone
{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Debug|iPhone.Build.0 = Debug|iPhone
{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Release|iPhone.ActiveCfg = Release|iPhone
{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Release|iPhone.Build.0 = Release|iPhone
{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = sample.csproj
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions RedLaser/binding/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BTOUCH=/Developer/MonoTouch/usr/bin/btouch
BUILDVER=build98
VERSION=3.1.2
BUILDVER=build139
VERSION=3.2.4

all: RedLaser.dll

Expand Down
3 changes: 3 additions & 0 deletions RedLaser/binding/redlaser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ notifies its delegate of what it found.
*/
[BaseType (typeof (UIViewController))]
interface BarcodePickerController {
[Export ("prepareToScan")]
void PrepareToScan ();

[Export ("pauseScanning")]
void PauseScanning ();

Expand Down

0 comments on commit 903646f

Please sign in to comment.