From f8901f2c8f453849864c6e4e4e4a29a45aac7457 Mon Sep 17 00:00:00 2001 From: Kaustav Chaudhuri Date: Fri, 19 May 2023 12:23:59 +0530 Subject: [PATCH] Few Required nuget packages added --- .../GMCabsDriverAssistantSolution.csproj | 2 + .../GMCabsDriverAssistantApplication.cs | 126 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 GMCabsDriverAssistantSolution/Platforms/Android/GMCabsDriverAssistantApplication.cs diff --git a/GMCabsDriverAssistantSolution/GMCabsDriverAssistantSolution.csproj b/GMCabsDriverAssistantSolution/GMCabsDriverAssistantSolution.csproj index 5776ffe..90bd9f9 100644 --- a/GMCabsDriverAssistantSolution/GMCabsDriverAssistantSolution.csproj +++ b/GMCabsDriverAssistantSolution/GMCabsDriverAssistantSolution.csproj @@ -105,8 +105,10 @@ + + diff --git a/GMCabsDriverAssistantSolution/Platforms/Android/GMCabsDriverAssistantApplication.cs b/GMCabsDriverAssistantSolution/Platforms/Android/GMCabsDriverAssistantApplication.cs new file mode 100644 index 0000000..a5b0e32 --- /dev/null +++ b/GMCabsDriverAssistantSolution/Platforms/Android/GMCabsDriverAssistantApplication.cs @@ -0,0 +1,126 @@ +using Android.App; +using Android.OS; +using Android.Runtime; +using Android.Util; +using AndroidX.Core.App; +using Plugin.FirebasePushNotification; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GMCabsDriverAssistantSolution.Platforms.Android +{ +#if DEBUG + [Application(Debuggable = true, NetworkSecurityConfig = "@xml/network_security_config")] +#else + [Application(Debuggable = false)] +#endif + //[MetaData("com.google.firebase.messaging.default_notification_icon", Resource = "@drawable/ic_stat_ic_notification")] + //[MetaData("com.google.firebase.messaging.default_notification_color", Resource = "@color/color_notification_icon")] + public class GMCabsDriverAssistantApplication : Microsoft.Maui.Controls.Application + { + // #region Constants + // public const string TAG = nameof(GMCabsDriverAssistantApplication); + // public static string SILENT_NOTIFICATION_CHANNEL_ID = "GMCabsDriverAssistantSilentNotificationChannel"; + // public static string SILENT_NOTIFICATION_CHANNEL_NAME = "GM Cabs Silent Notification Channel"; + // public static string SOUND_NOTIFICATION_CHANNEL_ID = "GMCabsDriverAssistantChannel"; + // public static string SOUND_NOTIFICATION_CHANNEL_NAME = "GM Cabs Notification Channel"; + // public static string SYSTEM_SOUND_NOTIFICATION_CHANNEL_ID = "GMCabsDriverAssistantSystemChannel"; + // public static string SYSTEM_SOUND_NOTIFICATION_CHANNEL_NAME = "GM Cabs System Notification Channel"; + // #endregion + + // public GMCabsDriverAssistantApplication(IntPtr handle, JniHandleOwnership transfer) + // : base(handle, transfer) + // { + + // } + + // public override void OnCreate() + // { + // base.OnCreate(); + + // //FirebasePushNotificationManager.Initialize(this, true); + // FirebasePushNotificationManager.Initialize(this, false); + + // CrossFirebasePushNotification.Current.OnNotificationReceived += Current_OnNotificationReceived; + // } + + // [Obsolete] + // private void Current_OnNotificationReceived(object source, FirebasePushNotificationDataEventArgs e) + // { + // var soundFileName = "newbooking"; + // Log.Debug(TAG, "Received on Android"); + // string channelId = string.Empty; + // string channelName = string.Empty; + // NotificationCompat.Builder notificationBuilder = null; + // NotificationChannel channel = null; + // var data = e.Data; + // if (data != null && e.Data.ContainsKey("title")) + // { + // /* Custom Sound Notification Channel */ + // if (data["title"].ToString() == "Booking Available") + // { + // channelId = SOUND_NOTIFICATION_CHANNEL_ID; + // channelName = SOUND_NOTIFICATION_CHANNEL_NAME; + // notificationBuilder = new NotificationCompat + // .Builder(this, channelId) + // .SetSmallIcon(Resource.Drawable.ic_stat_ic_notification) + // //.SetColor(GetColor(Resource.Color.color_notification_icon)) + // .SetContentTitle(data.ContainsKey("title") ? data["title"].ToString() : "") + // .SetContentText(data.ContainsKey("body") ? data["body"].ToString() : "") + // .SetPriority((int)NotificationImportance.Max) + // .SetAutoCancel(true); + + + // channel = new NotificationChannel(channelId, channelName, NotificationImportance.Max); + // channel.SetSound(global::Android.Net.Uri.Parse("android.resource://au.com.gmcabs.driverassistant/raw/" + soundFileName), null); + // } + // /* Silent Notification Channel */ + // else if (data["title"].ToString() == "Configuration") + // { + // channelId = SILENT_NOTIFICATION_CHANNEL_ID; + // channelName = SILENT_NOTIFICATION_CHANNEL_NAME; + // notificationBuilder = new NotificationCompat + // .Builder(this, channelId) + // .SetSmallIcon(Resource.Drawable.ic_stat_ic_notification) + // //.SetColor(GetColor(Resource.Color.color_notification_icon)) + // .SetContentTitle(data.ContainsKey("title") ? data["title"].ToString() : "") + // .SetContentText(data.ContainsKey("body") ? data["body"].ToString() : "") + // .SetPriority((int)NotificationImportance.Low) + // .SetNotificationSilent() + // .SetAutoCancel(true); + + // channel = new NotificationChannel(channelId, channelName, NotificationImportance.Low); + // } + // /* System Sound Notification Channel */ + // else + // { + // channelId = SYSTEM_SOUND_NOTIFICATION_CHANNEL_ID; + // channelName = SYSTEM_SOUND_NOTIFICATION_CHANNEL_NAME; + // notificationBuilder = new NotificationCompat + // .Builder(this, channelId) + // .SetSmallIcon(Resource.Drawable.ic_stat_ic_notification) + // //.SetColor(GetColor(Resource.Color.color_notification_icon)) + // .SetContentTitle(data.ContainsKey("title") ? data["title"].ToString() : "") + // .SetContentText(data.ContainsKey("body") ? data["body"].ToString() : "") + // .SetPriority((int)NotificationImportance.Max) + // .SetAutoCancel(true); + + // channel = new NotificationChannel(channelId, channelName, NotificationImportance.Max); + // } + + + // NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService); + + // if (Build.VERSION.SdkInt >= BuildVersionCodes.O) + // { + // notificationManager.CreateNotificationChannel(channel); + // } + + // notificationManager.Notify(DateTime.Now.Millisecond, notificationBuilder.Build()); + // } + // } + } +}