You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
6.7 KiB

  1. using Android.App;
  2. using Android.OS;
  3. using Android.Runtime;
  4. using Android.Util;
  5. using AndroidX.Core.App;
  6. using Plugin.FirebasePushNotification;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace GMCabsDriverAssistantSolution.Platforms.Android
  13. {
  14. #if DEBUG
  15. [Application(Debuggable = true, NetworkSecurityConfig = "@xml/network_security_config")]
  16. #else
  17. [Application(Debuggable = false)]
  18. #endif
  19. //[MetaData("com.google.firebase.messaging.default_notification_icon", Resource = "@drawable/ic_stat_ic_notification")]
  20. //[MetaData("com.google.firebase.messaging.default_notification_color", Resource = "@color/color_notification_icon")]
  21. public class GMCabsDriverAssistantApplication : Microsoft.Maui.Controls.Application
  22. {
  23. // #region Constants
  24. // public const string TAG = nameof(GMCabsDriverAssistantApplication);
  25. // public static string SILENT_NOTIFICATION_CHANNEL_ID = "GMCabsDriverAssistantSilentNotificationChannel";
  26. // public static string SILENT_NOTIFICATION_CHANNEL_NAME = "GM Cabs Silent Notification Channel";
  27. // public static string SOUND_NOTIFICATION_CHANNEL_ID = "GMCabsDriverAssistantChannel";
  28. // public static string SOUND_NOTIFICATION_CHANNEL_NAME = "GM Cabs Notification Channel";
  29. // public static string SYSTEM_SOUND_NOTIFICATION_CHANNEL_ID = "GMCabsDriverAssistantSystemChannel";
  30. // public static string SYSTEM_SOUND_NOTIFICATION_CHANNEL_NAME = "GM Cabs System Notification Channel";
  31. // #endregion
  32. // public GMCabsDriverAssistantApplication(IntPtr handle, JniHandleOwnership transfer)
  33. // : base(handle, transfer)
  34. // {
  35. // }
  36. // public override void OnCreate()
  37. // {
  38. // base.OnCreate();
  39. // //FirebasePushNotificationManager.Initialize(this, true);
  40. // FirebasePushNotificationManager.Initialize(this, false);
  41. // CrossFirebasePushNotification.Current.OnNotificationReceived += Current_OnNotificationReceived;
  42. // }
  43. // [Obsolete]
  44. // private void Current_OnNotificationReceived(object source, FirebasePushNotificationDataEventArgs e)
  45. // {
  46. // var soundFileName = "newbooking";
  47. // Log.Debug(TAG, "Received on Android");
  48. // string channelId = string.Empty;
  49. // string channelName = string.Empty;
  50. // NotificationCompat.Builder notificationBuilder = null;
  51. // NotificationChannel channel = null;
  52. // var data = e.Data;
  53. // if (data != null && e.Data.ContainsKey("title"))
  54. // {
  55. // /* Custom Sound Notification Channel */
  56. // if (data["title"].ToString() == "Booking Available")
  57. // {
  58. // channelId = SOUND_NOTIFICATION_CHANNEL_ID;
  59. // channelName = SOUND_NOTIFICATION_CHANNEL_NAME;
  60. // notificationBuilder = new NotificationCompat
  61. // .Builder(this, channelId)
  62. // .SetSmallIcon(Resource.Drawable.ic_stat_ic_notification)
  63. // //.SetColor(GetColor(Resource.Color.color_notification_icon))
  64. // .SetContentTitle(data.ContainsKey("title") ? data["title"].ToString() : "")
  65. // .SetContentText(data.ContainsKey("body") ? data["body"].ToString() : "")
  66. // .SetPriority((int)NotificationImportance.Max)
  67. // .SetAutoCancel(true);
  68. // channel = new NotificationChannel(channelId, channelName, NotificationImportance.Max);
  69. // channel.SetSound(global::Android.Net.Uri.Parse("android.resource://au.com.gmcabs.driverassistant/raw/" + soundFileName), null);
  70. // }
  71. // /* Silent Notification Channel */
  72. // else if (data["title"].ToString() == "Configuration")
  73. // {
  74. // channelId = SILENT_NOTIFICATION_CHANNEL_ID;
  75. // channelName = SILENT_NOTIFICATION_CHANNEL_NAME;
  76. // notificationBuilder = new NotificationCompat
  77. // .Builder(this, channelId)
  78. // .SetSmallIcon(Resource.Drawable.ic_stat_ic_notification)
  79. // //.SetColor(GetColor(Resource.Color.color_notification_icon))
  80. // .SetContentTitle(data.ContainsKey("title") ? data["title"].ToString() : "")
  81. // .SetContentText(data.ContainsKey("body") ? data["body"].ToString() : "")
  82. // .SetPriority((int)NotificationImportance.Low)
  83. // .SetNotificationSilent()
  84. // .SetAutoCancel(true);
  85. // channel = new NotificationChannel(channelId, channelName, NotificationImportance.Low);
  86. // }
  87. // /* System Sound Notification Channel */
  88. // else
  89. // {
  90. // channelId = SYSTEM_SOUND_NOTIFICATION_CHANNEL_ID;
  91. // channelName = SYSTEM_SOUND_NOTIFICATION_CHANNEL_NAME;
  92. // notificationBuilder = new NotificationCompat
  93. // .Builder(this, channelId)
  94. // .SetSmallIcon(Resource.Drawable.ic_stat_ic_notification)
  95. // //.SetColor(GetColor(Resource.Color.color_notification_icon))
  96. // .SetContentTitle(data.ContainsKey("title") ? data["title"].ToString() : "")
  97. // .SetContentText(data.ContainsKey("body") ? data["body"].ToString() : "")
  98. // .SetPriority((int)NotificationImportance.Max)
  99. // .SetAutoCancel(true);
  100. // channel = new NotificationChannel(channelId, channelName, NotificationImportance.Max);
  101. // }
  102. // NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService);
  103. // if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
  104. // {
  105. // notificationManager.CreateNotificationChannel(channel);
  106. // }
  107. // notificationManager.Notify(DateTime.Now.Millisecond, notificationBuilder.Build());
  108. // }
  109. // }
  110. }
  111. }