You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello MAUI community.
Im in a bit of a bind. My app is used by security guards.
One part of the app is that dispatch can send alarm notifications to a security guard thats driving around notifying him of a potential burglary.
As you may imagine this is a high importance notification.
This works all well and good in regular use. Untill the security guard's phone connects to android auto.
Then the notification is just shown on the device and the sound that normally plays is silent.
So a guard can go a while without noticing.
So far I tried the following.
In my Android platform files.
In my notification handler I added a carExtender.
varnotificationBuilder=newNotificationCompat.Builder(context,chanId).SetSmallIcon(smallIconResource).SetContentTitle(title).SetContentText(message).SetAutoCancel(true).SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()).SetContentIntent(pendingIntent).SetCategory(NotificationCompat.CategoryMessage).SetPriority(NotificationCompat.PriorityHigh).SetVisibility(NotificationCompat.VisibilityPublic).SetAllowSystemGeneratedContextualActions(true);varcarExtender=newNotificationCompat.CarExtender().SetColor(notificationColor??Color.Blue).SetLargeIcon(null)// Optional: you can set a car-specific large icon.SetUnreadConversation(null);// We're using MessagingStyle insteadnotificationBuilder.Extend(carExtender);
I tried changing the style and adding actions.
varappName=context.ApplicationInfo.LoadLabel(context.PackageManager);varsender=newAndroidX.Core.App.Person.Builder().SetName(appName).SetImportant(true).Build();varmessages=newList<NotificationCompat.MessagingStyle.Message>{newNotificationCompat.MessagingStyle.Message(message,Java.Lang.JavaSystem.CurrentTimeMillis(),sender)};varmessagingStyle=newNotificationCompat.MessagingStyle(sender).SetConversationTitle(title).SetGroupConversation(false);foreach(varmsginmessages){messagingStyle.AddMessage(msg);}notificationBuilder.SetStyle(messagingStyle);varAcceptIntent=newIntent(context,typeof(PushNotificationReadReceiver));AcceptIntent.SetAction("ACTION_ACCEPT");AcceptIntent.PutExtra("notification_id",notifyId);AcceptIntent.PutExtra("message",message);AcceptIntent.PutExtras(extras);varreadPendingIntent=PendingIntent.GetBroadcast(context,1,AcceptIntent,PendingIntentFlags.UpdateCurrent|PendingIntentFlags.Mutable);varAcceptAction=newNotificationCompat.Action.Builder(0,// You'll need this drawable resource"Accepteren",readPendingIntent).SetSemanticAction(NotificationCompat.Action.SemanticActionMarkAsRead).Build();vardeclineIntent=newIntent(context,typeof(PushNotificationReadReceiver));declineIntent.SetAction("ACTION_DECLINE");declineIntent.PutExtra("notification_id",notifyId);declineIntent.PutExtras(extras);vardeclinePendingIntent=PendingIntent.GetBroadcast(context,3,// Unique request codedeclineIntent,PendingIntentFlags.UpdateCurrent|PendingIntentFlags.Mutable);vardeclineAction=newNotificationCompat.Action.Builder(0,// No icon"Weigeren",declinePendingIntent).Build();notificationBuilder.AddAction(AcceptAction);notificationBuilder.AddAction(declineAction);
My notification Channel
varnotificationchannel=newNotificationChannel("MyChannel","MyChannel",NotificationImportance.High);varsounduri=Android.Net.Uri.Parse("android.resource://"+PackageName+"/"+MyApp.Resource.Raw.horn);vartype=newAudioAttributes.Builder().SetContentType(AudioContentType.Sonification).SetUsage(AudioUsageKind.Notification).SetLegacyStreamType(Android.Media.Stream.Notification).Build();notificationchannel.SetSound(sounduri,type);notificationchannel.SetShowBadge(true);notificationchannel.EnableLights(true);notificationchannel.EnableVibration(true);notificationchannel.LockscreenVisibility=NotificationVisibility.Public;varmanager=(NotificationManager)GetSystemService(NotificationService);NotificationChannelexistingChannel=manager.GetNotificationChannel("MyChannel");if(existingChannel!=null){// Delete the existing channelmanager.DeleteNotificationChannel("MyChannel");}manager.CreateNotificationChannel(notificationchannel);
Added the following to my manifest
<uses-featureandroid:name="android.hardware.type.automotive"android:required="false" />
inside my application
<meta-dataandroid:name="com.google.android.gms.car.application"android:resource="@xml/automotive_app_desc" />
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello MAUI community.
Im in a bit of a bind. My app is used by security guards.
One part of the app is that dispatch can send alarm notifications to a security guard thats driving around notifying him of a potential burglary.
As you may imagine this is a high importance notification.
This works all well and good in regular use. Untill the security guard's phone connects to android auto.
Then the notification is just shown on the device and the sound that normally plays is silent.
So a guard can go a while without noticing.
So far I tried the following.
In my Android platform files.
In my notification handler I added a carExtender.
I tried changing the style and adding actions.
My notification Channel
Added the following to my manifest
But to no avail so far.
Beta Was this translation helpful? Give feedback.
All reactions