TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
220 stars 49 forks source link

Remove default notification #97

Closed Hantse closed 1 year ago

Hantse commented 1 year ago

Hello,

I've read all the documentation, and i search to remove the default "notification" system to handle and set notification myself with another plugin, it's possible to do it ? (https://github.com/thudugala/Plugin.LocalNotification)

Kr

TobiasBuchholz commented 1 year ago

For android you can change the appearance of the default push notification by setting the static NotificationBuilderProvider Func of the android FirebaseCloudMessagingImplementation class:

...
    FirebaseCloudMessagingImplementation.NotificationBuilderProvider = CreateNotificationBuilder;
...

private static NotificationCompat.Builder CreateNotificationBuilder(FCMNotification notification)
{
    return new NotificationCompat.Builder(_context, ChannelId)
        .SetSmallIcon(Resource.Drawable.ic_push)
        .TrySetBigPictureStyle(notification)
        .SetContentTitle(notification.Title)
        .SetContentText(notification.Body)
        .SetPriority(NotificationCompat.PriorityDefault)
        .SetAutoCancel(true);
}

For iOS I'm not sure how to achieve this, but I guess you'll need to add an iOS extension project to customize your push notifications. Last time I checked this wasn't possible for .NET MAUI applications yet, but maybe it's now. If you are successful implementing it that way, please let us now :)