Skip to content

Commit

Permalink
update SDKs and demo apps to 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloud authored and Cloud committed Aug 20, 2019
1 parent 8606549 commit 8e8ac41
Show file tree
Hide file tree
Showing 63 changed files with 939 additions and 280 deletions.
12 changes: 10 additions & 2 deletions AppCenter-Demo.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
# Visual Studio Version 16
VisualStudioVersion = 16.0.29209.152
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{274AB35C-68B4-4EFA-803B-8A7CFEC25EFC}"
EndProject
Expand Down Expand Up @@ -148,6 +148,7 @@ Global
{3B39B339-86C4-47EF-8F85-811220494CA6}.Debug|x86.Build.0 = Debug|Any CPU
{3B39B339-86C4-47EF-8F85-811220494CA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B39B339-86C4-47EF-8F85-811220494CA6}.Release|Any CPU.Build.0 = Release|Any CPU
{3B39B339-86C4-47EF-8F85-811220494CA6}.Release|Any CPU.Deploy.0 = Release|Any CPU
{3B39B339-86C4-47EF-8F85-811220494CA6}.Release|ARM.ActiveCfg = Release|Any CPU
{3B39B339-86C4-47EF-8F85-811220494CA6}.Release|ARM.Build.0 = Release|Any CPU
{3B39B339-86C4-47EF-8F85-811220494CA6}.Release|ARM64.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -218,6 +219,9 @@ Global
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|Any CPU.Build.0 = Debug|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|ARM.ActiveCfg = Debug|ARM
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|ARM.Build.0 = Debug|ARM
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|ARM64.ActiveCfg = Release|ARM64
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|ARM64.Build.0 = Release|ARM64
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|ARM64.Deploy.0 = Release|ARM64
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|iPhone.ActiveCfg = Debug|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|iPhone.Build.0 = Debug|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|x86
Expand All @@ -230,6 +234,9 @@ Global
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|Any CPU.Build.0 = Debug|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|ARM.ActiveCfg = Debug|ARM
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|ARM.Build.0 = Debug|ARM
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|ARM64.ActiveCfg = Release|ARM64
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|ARM64.Build.0 = Release|ARM64
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|ARM64.Deploy.0 = Release|ARM64
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|iPhone.ActiveCfg = Debug|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|iPhone.Build.0 = Debug|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.AppStore|iPhoneSimulator.ActiveCfg = Debug|x86
Expand Down Expand Up @@ -258,6 +265,7 @@ Global
{665362D9-5EE2-45DE-A907-25DC86999A68}.Debug|x86.Deploy.0 = Debug|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.Release|Any CPU.ActiveCfg = Release|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.Release|Any CPU.Build.0 = Release|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.Release|Any CPU.Deploy.0 = Release|x86
{665362D9-5EE2-45DE-A907-25DC86999A68}.Release|ARM.ActiveCfg = Release|ARM
{665362D9-5EE2-45DE-A907-25DC86999A68}.Release|ARM.Build.0 = Release|ARM
{665362D9-5EE2-45DE-A907-25DC86999A68}.Release|ARM.Deploy.0 = Release|ARM
Expand Down
Expand Up @@ -51,13 +51,13 @@
<Reference Include="Mono.Android" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="2.2.1-preview" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="2.2.1-preview" />
<PackageReference Include="Microsoft.AppCenter.Distribute" Version="2.2.1-preview" />
<PackageReference Include="Microsoft.AppCenter.Push" Version="2.2.1-preview" />
<PackageReference Include="Microsoft.AppCenter.Auth" Version="2.2.1-preview" />
<PackageReference Include="Microsoft.AppCenter.Data" Version="2.2.1-preview" />
<PackageReference Include="Xamarin.Forms" Version="4.1.0.581479" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="2.3.0-preview" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="2.3.0-preview" />
<PackageReference Include="Microsoft.AppCenter.Distribute" Version="2.3.0-preview" />
<PackageReference Include="Microsoft.AppCenter.Push" Version="2.3.0-preview" />
<PackageReference Include="Microsoft.AppCenter.Auth" Version="2.3.0-preview" />
<PackageReference Include="Microsoft.AppCenter.Data" Version="2.3.0-preview" />
<PackageReference Include="Xamarin.Forms" Version="4.1.0.673156" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down
27 changes: 25 additions & 2 deletions Apps/Contoso.Forms.Demo/Contoso.Forms.Demo.Droid/MainActivity.cs
Expand Up @@ -6,14 +6,18 @@
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Contoso.Forms.Demo.Droid;
using Com.Microsoft.Appcenter.Analytics;
using Com.Microsoft.Appcenter.Analytics.Channel;
using Com.Microsoft.Appcenter.Ingestion.Models;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Push;
using Xamarin.Forms;
using Contoso.Forms.Demo.Droid;

[assembly: Dependency(typeof(MainActivity))]
namespace Contoso.Forms.Demo.Droid
{
[Activity(Label = "ACFDemo", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[Activity(Label = "ACFDemo", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, LaunchMode = LaunchMode.SingleTop)]
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity, IClearCrashClick
{
public static readonly int FileAttachmentId = 1;
Expand All @@ -31,6 +35,7 @@ protected override void OnCreate(Bundle savedInstanceState)

Xamarin.Forms.Forms.Init(this, savedInstanceState);

AndroidAnalytics.SetListener(new AndroidAnalyticsListener());
LoadApplication(new App());
}

Expand Down Expand Up @@ -60,4 +65,22 @@ public void ClearCrashButton()
appCenterPreferences.Edit().Remove(CrashesUserConfirmationStorageKey).Apply();
}
}

public class AndroidAnalyticsListener : Java.Lang.Object, IAnalyticsListener
{
public void OnSendingFailed(ILog log, Java.Lang.Exception e)
{
AppCenterLog.Debug(App.LogTag, "Analytics listener OnSendingFailed with exception: " + e);
}

public void OnSendingSucceeded(ILog log)
{
AppCenterLog.Debug(App.LogTag, "Analytics listener OnSendingSucceeded");
}

public void OnBeforeSending(ILog log)
{
AppCenterLog.Debug(App.LogTag, "Analytics listener OnBeforeSendingEventLog");
}
}
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.microsoft.appcenter.xamarin.forms.demo" android:versionName="2.2.1-preview" android:versionCode="67">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.microsoft.appcenter.xamarin.forms.demo" android:versionName="2.3.0-preview" android:versionCode="68">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27" />
<application android:label="ACFDemo">
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
Expand Down
Expand Up @@ -23,8 +23,8 @@
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("2.2.1.0")]
[assembly: AssemblyInformationalVersion("2.2.1-preview")]
[assembly: AssemblyFileVersion("2.3.0.0")]
[assembly: AssemblyInformationalVersion("2.3.0-preview")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down
91 changes: 72 additions & 19 deletions Apps/Contoso.Forms.Demo/Contoso.Forms.Demo.UWP/App.xaml.cs
Expand Up @@ -3,41 +3,95 @@

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Push;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Devices.Geolocation;
using Windows.Globalization;
using Windows.Services.Maps;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace Contoso.Forms.Demo.UWP
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
private const string LogTag = "AppCenterXamarinDemo";

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
// Set the country before initialization occurs so App Center can send the field to the backend
// Note that the country code provided does not reflect the physical device location, but rather the
// country that corresponds to the culture it uses. You may wish to retrieve the country code using
// a different means, such as device location.
var geographicRegion = new GeographicRegion();
AppCenter.SetCountryCode(geographicRegion.CodeTwoLetter);
// Set the country before initialization occurs so App Center can send the field to the backend.
// We do not use await here because we don't need to wait for this task to complete,
// and await would block the UI in App constructor.
_ = SetCountryCode();
EventFilterHolder.Implementation = new EventFilterWrapper();
InitializeComponent();
Suspending += OnSuspending;
}

private static async Task SetCountryCode()
{
// The following country code is used only as a fallback for the main implementation.
// This fallback country code does not reflect the physical device location, but rather the
// country that corresponds to the culture it uses.
var countryCode = new GeographicRegion().CodeTwoLetter;
var accessStatus = await Geolocator.RequestAccessAsync();
switch (accessStatus)
{
case GeolocationAccessStatus.Allowed:
var geoLocator = new Geolocator
{
DesiredAccuracyInMeters = 100
};
var position = await geoLocator.GetGeopositionAsync();
var myLocation = new BasicGeoposition
{
Longitude = position.Coordinate.Point.Position.Longitude,
Latitude = position.Coordinate.Point.Position.Latitude
};
var pointToReverseGeocode = new Geopoint(myLocation);
try
{
MapService.ServiceToken = Constants.BingMapsAuthKey;
}
catch (SEHException)
{
AppCenterLog.Info(LogTag, "Please provide a valid Bing Maps authentication key. For more info see: https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/authentication-key");
}
var result = await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);
if (result.Status != MapLocationFinderStatus.Success || result.Locations == null || result.Locations.Count == 0)
{
break;
}

// The returned country code is in 3-letter format (ISO 3166-1 alpha-3).
// Below we convert it to ISO 3166-1 alpha-2 (two letter).
var country = result.Locations[0].Address.CountryCode;
countryCode = new GeographicRegion(country).CodeTwoLetter;
break;
case GeolocationAccessStatus.Denied:
AppCenterLog.Info(LogTag, "Geolocation access denied. In order to set country code in App Center, enable location service in Windows 10.");
break;
case GeolocationAccessStatus.Unspecified:
break;
}
AppCenter.SetCountryCode(countryCode);
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
Expand All @@ -48,8 +102,8 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
DebugSettings.EnableFrameRateCounter = true;
}
#endif
var rootFrame = Window.Current.Content as Frame;

Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
Expand All @@ -70,15 +124,14 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}

if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof (MainPage), e.Arguments);
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
Expand All @@ -88,7 +141,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
Expand All @@ -98,9 +151,9 @@ private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
Expand Down
Expand Up @@ -4,7 +4,7 @@
using Contoso.Forms.Demo.UWP;
using Xamarin.Forms;

[assembly: Dependency((typeof(ClearCrashes)))]
[assembly: Dependency(typeof(ClearCrashes))]
namespace Contoso.Forms.Demo.UWP
{
public class ClearCrashes : IClearCrashClick
Expand Down
Expand Up @@ -94,6 +94,8 @@
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="ClearCrashes.cs" />
<Compile Include="EventFilter.cs" />
<Compile Include="EventFilterWrapper.cs" />
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -132,11 +134,11 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="2.2.1-preview" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="2.2.1-preview" />
<PackageReference Include="Microsoft.AppCenter.Distribute" Version="2.2.1-preview" />
<PackageReference Include="Microsoft.AppCenter.Push" Version="2.2.1-preview" />
<PackageReference Include="Xamarin.Forms" Version="4.1.0.581479" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="2.3.0-preview" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="2.3.0-preview" />
<PackageReference Include="Microsoft.AppCenter.Distribute" Version="2.3.0-preview" />
<PackageReference Include="Microsoft.AppCenter.Push" Version="2.3.0-preview" />
<PackageReference Include="Xamarin.Forms" Version="4.1.0.673156" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.8" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
Expand Down

0 comments on commit 8e8ac41

Please sign in to comment.