Skip to content

Commit

Permalink
fix: issue channel android
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Sep 5, 2024
1 parent af224e5 commit 934b799
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package ee.forgr.capacitor.uploader;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Build;

import com.getcapacitor.JSObject;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
Expand All @@ -18,8 +22,25 @@ public class UploaderPlugin extends Plugin {

private Uploader implementation;

private static final String CHANNEL_ID = "ee.forgr.capacitor.uploader.notification_channel_id";
private static final String CHANNEL_NAME = "Uploader Notifications";
private static final String CHANNEL_DESCRIPTION = "Notifications for file uploads";

private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);

NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription(CHANNEL_DESCRIPTION);

notificationManager.createNotificationChannel(channel);
}
}


@Override
public void load() {
createNotificationChannel();
implementation = new Uploader(
getContext(),
new RequestObserverDelegate() {
Expand Down

0 comments on commit 934b799

Please sign in to comment.