Skip to content

Commit

Permalink
MauiNotifications
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavAntonyuk committed Jun 26, 2024
1 parent 449804f commit c4eb699
Show file tree
Hide file tree
Showing 70 changed files with 1,294 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Auth/AuthServices/AuthServices.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Identity.Client" Version="4.60.3" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.61.3" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Auth/MauiAuth/MauiAuth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Auth/MauiAuthBlazor/MauiAuthBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Database/MauiTaskListApp/MauiTaskListApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.4" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion DynamicFab/DynamicFab.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions IPTVPlayer/IPTVPlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="m3uParser.NET" Version="1.0.17" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui.MediaElement" Version="3.1.0" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Maui.MediaElement" Version="4.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion KanbanBoard/KanbanBoard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion MauiAnimation/MauiAnimation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion MauiBank/MauiBank.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Plugin.Fingerprint" Version="3.0.0-beta.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MauiBells/MauiBells.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Plugin.Maui.Audio" Version="3.0.0-preview2" />
<PackageReference Include="Plugin.Maui.Audio" Version="3.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == '$(NetVersion)-android'">
Expand Down
4 changes: 2 additions & 2 deletions MauiBluetooth/MauiBluetooth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Plugin.BLE" Version="3.1.0-beta.3" />
<PackageReference Include="Plugin.BLE" Version="3.1.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion MauiCaptcha/MauiCaptcha.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MauiLocalization/MauiLocalization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions MauiMaps/MauiMaps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

<ItemGroup>
<PackageReference Include="AutoFixture" Version="5.0.0-preview0011" />
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.Maui.Maps" Version="2.0.1" />
<PackageReference Include="CommunityToolkit.Maui.Maps" Version="2.0.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion MauiMultiWindow/MauiMultiWindow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions MauiNotifications/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiNotifications"
x:Class="MauiNotifications.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
20 changes: 20 additions & 0 deletions MauiNotifications/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace MauiNotifications;

public partial class App
{
private readonly DeviceInstallationService deviceInstallationService;

public App(DeviceInstallationService deviceInstallationService)
{
this.deviceInstallationService = deviceInstallationService;
InitializeComponent();

MainPage = new AppShell();
}

protected override async void OnStart()
{
base.OnStart();
await deviceInstallationService.RegisterDevice();
}
}
15 changes: 15 additions & 0 deletions MauiNotifications/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="MauiNotifications.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiNotifications"
Shell.FlyoutBehavior="Disabled"
Title="MauiNotifications">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
9 changes: 9 additions & 0 deletions MauiNotifications/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MauiNotifications;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
22 changes: 22 additions & 0 deletions MauiNotifications/DeviceInstallationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace MauiNotifications;

using Microsoft.Azure.NotificationHubs;

public partial class DeviceInstallationService(IConnectivity connectivity, INotificationHubClient notificationHubClient)
{
public async Task RegisterDevice()
{
if (connectivity.NetworkAccess != NetworkAccess.Internet)
{
return;
}

var installation = await GetInstallation();
if (installation == null)
{
return;
}

await notificationHubClient.CreateOrUpdateInstallationAsync(installation);
}
}
36 changes: 36 additions & 0 deletions MauiNotifications/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiNotifications.MainPage">

<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />

<Label
Text="Hello, World!"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />

<Label
Text="Welcome to &#10;.NET Multi-platform App UI"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />

<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>

</ContentPage>
23 changes: 23 additions & 0 deletions MauiNotifications/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace MauiNotifications;

public partial class MainPage : ContentPage
{
int count = 0;

public MainPage()
{
InitializeComponent();
}

private void OnCounterClicked(object sender, EventArgs e)
{
count++;

if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";

SemanticScreenReader.Announce(CounterBtn.Text);
}
}
45 changes: 45 additions & 0 deletions MauiNotifications/MauiNotifications.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>MauiNotifications</RootNamespace>

<!-- Display name -->
<ApplicationTitle>MauiNotifications</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.vladislavantonyuk.mauinotifications</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

<!-- Custom Fonts -->

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="Microsoft.Azure.NotificationHubs" Version="4.2.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
<GoogleServicesJson Include="Platforms\Android\google-services.json" />
<PackageReference Include="Xamarin.Firebase.Messaging" Version="123.1.2.2" />
<PackageReference Include="Xamarin.Google.Dagger" Version="2.39.1" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions MauiNotifications/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace MauiNotifications;

using CommunityToolkit.Maui;
using Microsoft.Azure.NotificationHubs;
using Microsoft.Extensions.Logging;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<App>()
.UseMauiCommunityToolkit();

builder.Services.AddSingleton(Connectivity.Current);

builder.Services.AddSingleton<DeviceInstallationService>();

builder.Services.AddSingleton<INotificationHubClient, NotificationHubClient>(
_ => NotificationHubClient.CreateClientFromConnectionString("YOUR CONNECTION STRING", "MauiNotifications", true));

return builder.Build();
}
}
10 changes: 10 additions & 0 deletions MauiNotifications/Platforms/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
</manifest>
9 changes: 9 additions & 0 deletions MauiNotifications/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MauiNotifications;

using Android.App;
using Android.Content.PM;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
Loading

0 comments on commit c4eb699

Please sign in to comment.