Browse Source

[푸시][New] 백그라운드에서 받은 노티 처리
- 노티 메세지에 notification 속성과 data 속성이 같이 있으면, 백그라운드에서 수신 시 service 의 onRecivedMessage() 로 전달이 되지 않고 노티 터치 시 런쳐로 bundle이 전달된다.
- 이 경우 사용자가 노티를 터치하지 않고 지워버리면 '소식'에 저장할 수 없다.
- 구독하는 토픽 이름을 ios 와 분리하는 것으로 우선 해결

hyodong.min 6 years ago
parent
commit
011a324d8a

+ 45 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/activity/SplashActivity.java

@@ -4,16 +4,29 @@ import android.Manifest;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.util.Log;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Set;
+
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.disposables.CompositeDisposable;
 import io.reactivex.schedulers.Schedulers;
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.application.App;
+import kr.co.zumo.app.lifeplus.bean.PushBean;
 import kr.co.zumo.app.lifeplus.model.SuperModel;
+import kr.co.zumo.app.lifeplus.model.SuperModelInit;
 import kr.co.zumo.app.lifeplus.network.NetworkWatcher;
+import kr.co.zumo.app.lifeplus.supervisor.ActivityDeliveryHelper;
+import kr.co.zumo.app.lifeplus.supervisor.PushMessageManager;
 import kr.co.zumo.app.lifeplus.util.PermissionUtil;
 
 /**
@@ -36,10 +49,42 @@ public class SplashActivity extends ActivityBaseSetup {
 
     Context context = App.getInstance().getContext();
 
+    // has push message ?
+    Bundle bundle = getIntent().getExtras();
+    if (null != bundle) {
+      // push message 는 pageId 가 있어야한다.
+      if(bundle.get("pageId") != null ) {
+        Log.d("APP# SplashActivity | setup", "| extras: " + bundle);
+        JSONObject json = new JSONObject();
+        Set<String> keys = bundle.keySet();
+        for (String key : keys) {
+          try {
+            json.put(key, JSONObject.wrap(bundle.get(key)));
+          } catch (JSONException e) {
+            //Handle exception here
+          }
+        }
+
+        Gson gson = new GsonBuilder().create();
+
+        PushBean bean = gson.fromJson(json.toString(), PushBean.class);
+        Log.d("APP# SplashActivity | setup", "|" + bean.toJson());
+
+        SuperModelInit.instant(getApplicationContext());
+        PushMessageManager.onRecived(bean);
+
+        // fixme PushGateActivity 와 중복되는 부분이 있다.
+        ActivityDeliveryHelper.getInstance().setPackaging(bean);
+        SuperModel.getInstance().setPushLink(true);
+      }
+    }
+
     // 앱이 실행 중인지 판단한다.
     if (SuperModel.getInstance().isAppInitialized()) {
       Log.e("APP#  SplashActivity | onCreate", "|" + " restart from call...........");
+
       finish();
+      doOnLink();
     }
     else {
       Log.e("APP#  SplashActivity | onCreate", "|" + " first ...........................");