깃허브에서 소스 찍먹해보고있는 초보인데요

처음 설치하면 튕깁니다ㅠ 왜그럴까요?



package com.jcdev.newchat.services.notifications;


import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.BitmapFactory;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import com.jcdev.newchat.R;
import com.jcdev.newchat.view.ui.MessageActivity;
import com.jcdev.newchat.viewModel.LogInViewModel;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class MyFirebaseMessaging extends FirebaseMessagingService implements LifecycleOwner {

LogInViewModel logInViewModel = ViewModelProvider.AndroidViewModelFactory.getInstance(getApplication()).create(LogInViewModel.class);

@Override
public void onNewToken(@NonNull String s) {
super.onNewToken(s);

FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser firebaseUser = mAuth.getCurrentUser();

if (null != firebaseUser) {
updateToken(s);
}

}

private void updateToken(String newToken) {
logInViewModel.updateToken(newToken);
logInViewModel.successUpdateToken.observe((LifecycleOwner) this, new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {

}
});
}

@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
String sent = remoteMessage.getData().get("sent");
String user = remoteMessage.getData().get("user");

SharedPreferences preferences = getSharedPreferences("PREFS", MODE_PRIVATE);
String currentUser = preferences.getString("currentuser", "none");

FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser firebaseUser = mAuth.getCurrentUser();

assert sent != null;
if (firebaseUser != null && sent.equals(firebaseUser.getUid())) {
if (!currentUser.equals(user)) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
sendOreoNotification(remoteMessage);
}
sendNotification(remoteMessage);
}
}

}

@RequiresApi(api = Build.VERSION_CODES.O)
private void sendOreoNotification(RemoteMessage remoteMessage) {

String user = remoteMessage.getData().get("user");
String icon = remoteMessage.getData().get("icon");
String title = remoteMessage.getData().get("title");
String body = remoteMessage.getData().get("body");

RemoteMessage.Notification notification = remoteMessage.getNotification();

assert user != null;
int j = Integer.parseInt(user.replaceAll("[\\D]", ""));

Intent intent = new Intent(this, MessageActivity.class);
Bundle bundle = new Bundle();
bundle.putString("userId", user);
intent.putExtras(bundle);

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, j, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);

Uri defaultSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

OreoNotification oreoNotification = new OreoNotification(this);
Notification.Builder builder = oreoNotification.getOreoNotification(title, body, pendingIntent, defaultSound, icon);

int i = 0;
if (j > 0) {
i = j;
}

oreoNotification.getManager().notify(i, builder.build());
}

private void sendNotification(RemoteMessage remoteMessage) {
String user = remoteMessage.getData().get("user");
String icon = remoteMessage.getData().get("icon");
String title = remoteMessage.getData().get("title");
String body = remoteMessage.getData().get("body");

RemoteMessage.Notification notification = remoteMessage.getNotification();
assert user != null;
int j = Integer.parseInt(user.replaceAll("[\\D]", ""));
Intent intent = new Intent(this, MessageActivity.class);
Bundle bundle = new Bundle();
bundle.putString("userId", user);

intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

PendingIntent pendingIntent = PendingIntent.getActivity(this, j, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);

Uri defaultSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
assert icon != null;
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(this.getResources(),
R.mipmap.ic_launcher))
.setContentTitle(title)
.setContentText(body)
.setAutoCancel(true)
.setSound(defaultSound)
.setContentIntent(pendingIntent);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

int i = 0;
if (j > 0) {
i = j;
}

assert notificationManager != null;
notificationManager.notify(i, builder.build());
}

@NonNull
@Override
public Lifecycle getLifecycle() {
return null;
}
}