Skip to content

Commit

Permalink
Add Firebase Analytics to iOS app.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanolkies committed May 31, 2018
1 parent 5dd09c2 commit f4f297f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
19 changes: 9 additions & 10 deletions GAExample.iOS/AppDelegate.cs
@@ -1,16 +1,12 @@
using System; using Foundation;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit; using UIKit;


namespace GAExample.iOS namespace GAExample.iOS
{ {
// The UIApplicationDelegate for the application. This class is responsible for launching the // The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to // User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS. // application events from iOS.
[Register("AppDelegate")] [Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{ {
// //
Expand All @@ -22,9 +18,12 @@ public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsAppli
// //
public override bool FinishedLaunching(UIApplication app, NSDictionary options) public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{ {
global::Xamarin.Forms.Forms.Init(); global::Xamarin.Forms.Forms.Init();
LoadApplication(new App()); LoadApplication(new App());


Firebase.Core.App.Configure();
Firebase.Analytics.Analytics.LogEvent("app_open", null);

return base.FinishedLaunching(app, options); return base.FinishedLaunching(app, options);
} }
} }
Expand Down
8 changes: 7 additions & 1 deletion GAExample.iOS/GAExample.iOS.csproj
Expand Up @@ -27,6 +27,7 @@
<MtouchArch>x86_64</MtouchArch> <MtouchArch>x86_64</MtouchArch>
<MtouchLink>None</MtouchLink> <MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug> <MtouchDebug>true</MtouchDebug>
<MtouchExtraArgs>--registrar:static</MtouchExtraArgs>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType> <DebugType>none</DebugType>
Expand All @@ -37,6 +38,7 @@
<MtouchLink>None</MtouchLink> <MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch> <MtouchArch>x86_64</MtouchArch>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<MtouchExtraArgs>--registrar:static</MtouchExtraArgs>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -90,10 +92,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Main.cs" /> <Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<None Include="Entitlements.plist" /> <None Include="Entitlements.plist" />
<None Include="Info.plist" /> <None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="AppDelegate.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" /> <InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
Expand Down Expand Up @@ -150,6 +152,9 @@
<PackageReference Include="Xamarin.Forms"> <PackageReference Include="Xamarin.Forms">
<Version>3.0.0.482510</Version> <Version>3.0.0.482510</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Xamarin.Firebase.iOS.Analytics">
<Version>4.0.5.1</Version>
</PackageReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup> <ItemGroup>
Expand All @@ -160,5 +165,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<BundleResource Include="Resources\events.png" /> <BundleResource Include="Resources\events.png" />
<BundleResource Include="GoogleService-Info.plist" />
</ItemGroup> </ItemGroup>
</Project> </Project>
40 changes: 40 additions & 0 deletions GAExample.iOS/GoogleService-Info.plist
@@ -0,0 +1,40 @@
<?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>AD_UNIT_ID_FOR_BANNER_TEST</key>
<string>ca-app-pub-3940256099942544/2934735716</string>
<key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
<string>ca-app-pub-3940256099942544/4411468910</string>
<key>CLIENT_ID</key>
<string>508995298724-ukm9m485qj7csmuiku2iag4amo5n051l.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.508995298724-ukm9m485qj7csmuiku2iag4amo5n051l</string>
<key>API_KEY</key>
<string>AIzaSyCTj6tMt0sfTmOxw83CgFMfHOdsT4bhkQM</string>
<key>GCM_SENDER_ID</key>
<string>508995298724</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.ilanolkies.GAExample</string>
<key>PROJECT_ID</key>
<string>xamarin-example-19586</string>
<key>STORAGE_BUCKET</key>
<string>xamarin-example-19586.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<true/>
<key>IS_ANALYTICS_ENABLED</key>
<true/>
<key>IS_APPINVITE_ENABLED</key>
<false/>
<key>IS_GCM_ENABLED</key>
<true/>
<key>IS_SIGNIN_ENABLED</key>
<true/>
<key>GOOGLE_APP_ID</key>
<string>1:508995298724:ios:8f0beab4bafb48a0</string>
<key>DATABASE_URL</key>
<string>https://xamarin-example-19586.firebaseio.com</string>
</dict>
</plist>

0 comments on commit f4f297f

Please sign in to comment.