Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 958673d

Browse files
committed
Edits.
1 parent 1a3ce4d commit 958673d

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

LocalNotifications/LocalNotifications/LocalNotifications.Android/AndroidNotificationManager.cs

+20-20
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,6 @@ public void Initialize()
3535
Instance = this;
3636
}
3737

38-
public void Show(string title, string message)
39-
{
40-
Intent intent = new Intent(AndroidApp.Context, typeof(MainActivity));
41-
intent.PutExtra(TitleKey, title);
42-
intent.PutExtra(MessageKey, message);
43-
44-
PendingIntent pendingIntent = PendingIntent.GetActivity(AndroidApp.Context, pendingIntentId++, intent, PendingIntentFlags.UpdateCurrent);
45-
46-
NotificationCompat.Builder builder = new NotificationCompat.Builder(AndroidApp.Context, channelId)
47-
.SetContentIntent(pendingIntent)
48-
.SetContentTitle(title)
49-
.SetContentText(message)
50-
.SetLargeIcon(BitmapFactory.DecodeResource(AndroidApp.Context.Resources, Resource.Drawable.xamagonBlue))
51-
.SetSmallIcon(Resource.Drawable.xamagonBlue)
52-
.SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate);
53-
54-
Notification notification = builder.Build();
55-
manager.Notify(messageId++, notification);
56-
}
57-
5838
public void SendNotification(string title, string message, DateTime? notifyTime = null)
5939
{
6040
if (!channelInitialized)
@@ -89,6 +69,26 @@ public void ReceiveNotification(string title, string message)
8969
NotificationReceived?.Invoke(null, args);
9070
}
9171

72+
public void Show(string title, string message)
73+
{
74+
Intent intent = new Intent(AndroidApp.Context, typeof(MainActivity));
75+
intent.PutExtra(TitleKey, title);
76+
intent.PutExtra(MessageKey, message);
77+
78+
PendingIntent pendingIntent = PendingIntent.GetActivity(AndroidApp.Context, pendingIntentId++, intent, PendingIntentFlags.UpdateCurrent);
79+
80+
NotificationCompat.Builder builder = new NotificationCompat.Builder(AndroidApp.Context, channelId)
81+
.SetContentIntent(pendingIntent)
82+
.SetContentTitle(title)
83+
.SetContentText(message)
84+
.SetLargeIcon(BitmapFactory.DecodeResource(AndroidApp.Context.Resources, Resource.Drawable.xamagonBlue))
85+
.SetSmallIcon(Resource.Drawable.xamagonBlue)
86+
.SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate);
87+
88+
Notification notification = builder.Build();
89+
manager.Notify(messageId++, notification);
90+
}
91+
9292
void CreateNotificationChannel()
9393
{
9494
manager = (NotificationManager)AndroidApp.Context.GetSystemService(AndroidApp.NotificationService);

LocalNotifications/LocalNotifications/LocalNotifications.Android/Properties/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<uses-sdk android:minSdkVersion="21" />
44
<application android:label="LocalNotifications.Android"></application>
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6-
</manifest>
6+
</manifest>
Loading

0 commit comments

Comments
 (0)