|
|
@@ -23,9 +23,11 @@ import com.google.gson.JsonElement;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import kr.co.zumo.app.R;
|
|
|
-import kr.co.zumo.app.lifeplus.activity.MainActivity;
|
|
|
+import kr.co.zumo.app.lifeplus.activity.PushGateActivity;
|
|
|
import kr.co.zumo.app.lifeplus.bean.PushBean;
|
|
|
import kr.co.zumo.app.lifeplus.helper.FirebaseHelper;
|
|
|
+import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
+import kr.co.zumo.app.lifeplus.model.SuperModelInit;
|
|
|
import kr.co.zumo.app.lifeplus.supervisor.PushMessageManager;
|
|
|
|
|
|
|
|
|
@@ -59,6 +61,9 @@ public class FirebasePushService extends FirebaseMessagingService {
|
|
|
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
|
|
|
Log.d("APP# FirebasePushService | onMessageReceived", "|" + "From: " + remoteMessage.getFrom());
|
|
|
|
|
|
+ SuperModelInit.instant(getApplicationContext());
|
|
|
+
|
|
|
+
|
|
|
// Check if message contains a data payload.
|
|
|
if (remoteMessage.getData().size() > 0) {
|
|
|
Log.d("APP# FirebasePushService | onMessageReceived", "|" + "Message data payload: " + remoteMessage.getData());
|
|
|
@@ -71,10 +76,17 @@ public class FirebasePushService extends FirebaseMessagingService {
|
|
|
Log.d("APP# FirebasePushService | onMessageReceived", "|" + bean.toJson());
|
|
|
|
|
|
PushMessageManager.savePushMessages(new PushMessageManager(PushMessageManager.getPushMessages()).addPushBean(bean));
|
|
|
-
|
|
|
- sendNotification(bean.getTitle(), bean.getContents());
|
|
|
-
|
|
|
PushMessageBroker.getInstance().push(bean);
|
|
|
+
|
|
|
+ // 노티를 표시할지 구분
|
|
|
+ if (PushMessageManager.isEventCode(bean.getScreenCode()) && SuperModel.getInstance().getPreferences().isPushEventEnabled()) {
|
|
|
+ // event 코드이고 수신 설정 시
|
|
|
+ sendNotification(bean);
|
|
|
+ }
|
|
|
+ else if (PushMessageManager.isContentsCode(bean.getScreenCode()) && SuperModel.getInstance().getPreferences().isPushContentsAndService()) {
|
|
|
+ // 컨텐츠 코드이고 수신 설정 시
|
|
|
+ sendNotification(bean);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Check if message contains a notification payload.
|
|
|
@@ -91,15 +103,14 @@ public class FirebasePushService extends FirebaseMessagingService {
|
|
|
|
|
|
/**
|
|
|
* Create and show a simple notification containing the received FCM message.
|
|
|
- *
|
|
|
- * @param title FCM message title received.
|
|
|
- * @param messageBody FCM message body received.
|
|
|
*/
|
|
|
- private void sendNotification(String title, String messageBody) {
|
|
|
- Intent intent = new Intent(this, MainActivity.class);
|
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
|
|
|
- PendingIntent.FLAG_ONE_SHOT);
|
|
|
+ private void sendNotification(PushBean bean) {
|
|
|
+ String title = bean.getTitle();
|
|
|
+ String messageBody = bean.getContents();
|
|
|
+ Intent intent = new Intent(this, PushGateActivity.class);
|
|
|
+// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
+ intent.putExtra(PushGateActivity.PUSH_JSON, bean.toJson());
|
|
|
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT);
|
|
|
|
|
|
String channelId = "lifeplus_channel_id";
|
|
|
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|