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.
46 lines
1.8 KiB
46 lines
1.8 KiB
using Android.App;
|
|
using Android.Content;
|
|
using Android.OS;
|
|
using Android.Runtime;
|
|
using Android.Views;
|
|
using Android.Widget;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using PhilExample.Droid.Services;
|
|
using PhilExample.Droid.Utils;
|
|
using PhilExample.Services;
|
|
|
|
[assembly: Xamarin.Forms.Dependency(typeof(InsertionNotificationService))]
|
|
namespace PhilExample.Droid.Services
|
|
{
|
|
public class InsertionNotificationService : IInsertionNotificationService
|
|
{
|
|
const string NOTIFICATION_CHANNEL_ID = "1000";
|
|
const string NOTIFICATION_CHANNEL_NAME = "PhilExample_noti_2";
|
|
const string NOTIFICATION_CHANNEL_DESCR = "PhilExample_insertion_noti";
|
|
|
|
static int notiID = 2000;
|
|
static int NotiID { get => notiID > 2020
|
|
? (notiID = 2000) //TODO: Test if this assignment does what its supposed to (limit notifications to 20 at max, update old notis)
|
|
: notiID++; }
|
|
|
|
|
|
public void PublishNotification(string title, string descr, int insertionID)
|
|
{
|
|
NotificationHelper.CreateNotificationChannel(NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_NAME, NOTIFICATION_CHANNEL_DESCR);
|
|
|
|
var notification = new Notification.Builder(MainActivity._THIS, NOTIFICATION_CHANNEL_ID)
|
|
//.SetContentIntent(onClickIntent)
|
|
.SetContentTitle(title)
|
|
.SetContentText(descr)
|
|
.SetSmallIcon(Resource.Drawable.abc_btn_default_mtrl_shape)
|
|
.Build();
|
|
|
|
NotificationHelper.GetAndroidNotificationManager().Notify(NotiID, notification);
|
|
}
|
|
|
|
|
|
}
|
|
} |