xamarin plugin error Java.Lang.IllegalArgumentException

-1

Error:

Java.Lang.IllegalArgumentException: Invalid notification (no valid small icon): 
Notification(channel=1 pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)

i am setting up a basic plugin for local notification on android phone. I followed the guide on github but getting an error. any ideas?

btw, I checked and NotificationRequest doesnt have SmallIcon

Ref: https://github.com/thudugala/Plugin.LocalNotification

  void SendButtonClicked(object sender, EventArgs e)
  {
       var notification = new NotificationRequest
     {
        NotificationId = 100,
        Title = "Test",
        Description = "Test Description",
        ReturningData = "Dummy data", 
        NotifyTime = DateTime.Now.AddSeconds(30) 
    };
   NotificationCenter.Current.Show(notification);
}

android version

   <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />

Android

   protected override async void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        NotificationCenter.CreateNotificationChannel();
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        LoadApplication(new App());
    }

   protected override void OnNewIntent(Intent intent)
    {
        NotificationCenter.NotifyNotificationTapped(intent);
        base.OnNewIntent(intent);
    }

Full Error:

[0:] Java.Lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=1 pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0)
  at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <94b04e1756104d1fa1d144932ae2720c>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <94b04e1756104d1fa1d144932ae2720c>:0 
  at Android.App.NotificationManager.Notify (System.Int32 id, Android.App.Notification notification) [0x0003a] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.App.NotificationManager.cs:1551 
  at Plugin.LocalNotification.Platform.Droid.NotificationServiceImpl.ShowNow (Plugin.LocalNotification.NotificationRequest request, System.Boolean cancelBeforeShow) [0x003a9] in <da779fe7936d4c7a89f47ac2915456d7>:0 
  at Plugin.LocalNotification.Platform.Droid.NotificationServiceImpl.Show (Plugin.LocalNotification.NotificationRequest notificationRequest) [0x0003c] in <da779fe7936d4c7a89f47ac2915456d7>:0 
  --- End of managed Java.Lang.IllegalArgumentException stack trace ---
c#
android
xamarin
xamarin.forms
xamarin.android
asked on Stack Overflow May 19, 2021 by Star Gates • edited May 19, 2021 by Star Gates

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0