|
|
@ -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());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |