Sfoglia il codice sorgente

1.修改接收推送

FailedToRead 3 anni fa
parent
commit
5eaeff553c

BIN
.idea/caches/build_file_checksums.ser


+ 1 - 1
.idea/modules/app/proj.android-studio.efunbox-ott-launcher.iml

@@ -10,7 +10,7 @@
     </facet>
     <facet type="native-android-gradle" name="Native-Android-Gradle">
       <configuration>
-        <option name="SELECTED_BUILD_VARIANT" value="channel_360Debug-armeabi-v7a" />
+        <option name="SELECTED_BUILD_VARIANT" value="channel_efunboxRelease-armeabi-v7a" />
       </configuration>
     </facet>
     <facet type="android" name="Android">

+ 9 - 2
app/AndroidManifest.xml

@@ -122,7 +122,8 @@
         <activity
                 android:name=".push.MfrMessageActivity"
                 android:exported="true"
-                android:launchMode="singleTask">
+                android:launchMode="singleTask"
+                android:theme="@style/transcutestyle">
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
 
@@ -130,7 +131,7 @@
                 <category android:name="android.intent.category.BROWSABLE" />
 
                 <data
-                        android:host="com.edufound.mobile"
+                        android:host="${applicationId}"
                         android:path="/thirdpush"
                         android:scheme="agoo" />
             </intent-filter>
@@ -159,6 +160,12 @@
                 android:name="com.vivo.push.app_id"
                 android:value="18875" />
         <!-- 友盟厂商VIVOend-->
+
+        <!-- 华为-->
+        <meta-data
+                android:name="com.huawei.hms.client.appid"
+                android:value="appid=10658746" />
+        <!-- 华为end-->
         <!--友盟start-->
         <meta-data
                 android:name="UMENG_APPKEY"

+ 10 - 0
app/build.gradle

@@ -112,6 +112,8 @@ android {
                             newoutputFile = "\\广西优学\\"
                         } else if (channel == ("2007")) {
                             newoutputFile = "\\vivo\\"
+                        } else if (channel == ("2007")) {
+                            newoutputFile = "\\oppo\\"
                         }
                         output.outputFileName = new File(newoutputFile, fileName)
                     }
@@ -225,6 +227,14 @@ android {
                     appIcon: "@drawable/icon",
             ]
         }
+        //字节跳动
+        channel_oppo {
+            signingConfig signingConfigs.release
+            manifestPlaceholders = [
+                    appCode: "2004",
+                    appIcon: "@drawable/icon",
+            ]
+        }
     }
     productFlavors.all {
         flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: manifestPlaceholders.appCode, icon: manifestPlaceholders.appIcon]

+ 32 - 19
app/src/com/edufound/mobile/push/MfrMessageActivity.java

@@ -11,6 +11,7 @@ import com.edufound.mobile.R;
 import com.umeng.message.UmengNotifyClickActivity;
 
 import org.android.agoo.common.AgooConstants;
+import org.cocos2dx.javascript.AppActivity;
 import org.cocos2dx.javascript.util.Logger;
 
 public class MfrMessageActivity extends UmengNotifyClickActivity {
@@ -27,24 +28,36 @@ public class MfrMessageActivity extends UmengNotifyClickActivity {
     @Override
     public void onMessage(Intent intent) {
         super.onMessage(intent);
-        Bundle bundle = intent.getExtras();
-        if (bundle != null) {
-            Logger.e("bundle: " + bundle);
-        }
-        String body = intent.getStringExtra(AgooConstants.MESSAGE_BODY);
-        Logger.e("body: " + body);
-        if (!TextUtils.isEmpty(body)) {
-//            runOnUiThread(() -> ((TextView) findViewById(R.id.tv)).setText(body));
-            AlertDialog.Builder builder = new AlertDialog.Builder((this));
-            builder.setMessage(body);
-            builder.setTitle("消息通知");
-            builder.setNegativeButton("确定", new DialogInterface.OnClickListener() {
-                @Override
-                public void onClick(DialogInterface dialog, int which) {
-                    dialog.dismiss();
-                    mActivity.finish();
-                }
-            });
-        }
+//        Logger.e("MfrMessageActivity---message");
+//        if (intent == null) {
+//            intent = getIntent();
+//        }
+//        Bundle bundle = intent.getExtras();
+//        if (bundle != null) {
+//            Logger.e("bundle: " + bundle);
+//        }
+//        String body = intent.getStringExtra(AgooConstants.MESSAGE_BODY);
+//        Logger.e("body: " + body);
+//        if (!TextUtils.isEmpty(body)) {
+//            runOnUiThread(new Runnable() {
+//                @Override
+//                public void run() {
+//                    AlertDialog.Builder builder = new AlertDialog.Builder((mActivity));
+//                    builder.setMessage(body);
+//                    builder.setTitle("消息通知");
+//                    builder.setNegativeButton("确定", new DialogInterface.OnClickListener() {
+//                        @Override
+//                        public void onClick(DialogInterface dialog, int which) {
+//                            dialog.dismiss();
+//                            mActivity.finish();
+//                        }
+//                    });
+//                    builder.create().show();
+//                }
+//            });
+        Intent toMain = new Intent(mActivity, AppActivity.class);
+        mActivity.startActivity(toMain);
+        finish();
+
     }
 }

+ 3 - 1
src/org/cocos2dx/javascript/AppActivity.java

@@ -40,6 +40,8 @@ import com.edufound.mobile.R;
 import com.google.gson.Gson;
 import com.umeng.analytics.MobclickAgent;
 import com.umeng.commonsdk.UMConfigure;
+import com.umeng.message.inapp.IUmengInAppMsgCloseCallback;
+import com.umeng.message.inapp.InAppMessageManager;
 
 import org.cocos2dx.javascript.presenter.MainPresenter;
 import org.cocos2dx.javascript.util.Consts;
@@ -73,9 +75,9 @@ public class AppActivity extends Cocos2dxActivity {
             return;
         }
         // DO OTHER INITIALIZATION BELOW
+        showSplash();
         sendBroadcast(new Intent("android.intent.action.STATUSBAR_DISABLE"));
         SDKWrapper.getInstance().init(this);
-        showSplash();
         mPresenter = new MainPresenter(this);
     }
 

+ 47 - 1
src/org/cocos2dx/javascript/application/EApplication.java

@@ -2,6 +2,8 @@ package org.cocos2dx.javascript.application;
 
 import android.app.Application;
 import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
 
 
 import com.umeng.commonsdk.UMConfigure;
@@ -10,6 +12,10 @@ import com.umeng.message.PushAgent;
 import com.umeng.message.api.UPushRegisterCallback;
 import com.xiaomi.mipush.sdk.PushMessageHelper;
 
+import org.android.agoo.huawei.HuaWeiRegister;
+import org.android.agoo.oppo.OppoRegister;
+import org.android.agoo.vivo.VivoRegister;
+import org.android.agoo.xiaomi.MiPushRegistar;
 import org.cocos2dx.javascript.util.Consts;
 import org.cocos2dx.javascript.util.CrashHandler;
 import org.cocos2dx.javascript.util.Logger;
@@ -20,7 +26,7 @@ public class EApplication extends Application {
     @Override
     public void onCreate() {
         super.onCreate();
-        Consts.mApplicatonContext = getApplicationContext();
+        Consts.mApplicatonContext = this;
         UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, "dfc59afd6dc6b1550ff1c2e0c7eb10fd");
         UMConfigure.setLogEnabled(true);
 //        MediaPlayerManager.getDefault().init(Consts.mApplicatonContext, getPackageName());
@@ -38,18 +44,58 @@ public class EApplication extends Application {
             //若不是主进程(":channel"结尾的进程),直接初始化sdk,不可在子线程中执行
             PushHelper.init(getApplicationContext());
         }
+        PushAgent.getInstance(getApplicationContext()).onAppStart();
     }
 
     @Override
     protected void attachBaseContext(Context base) {
         super.attachBaseContext(base);
     }
+
+    public static String getChannelName() {
+        String code = "";
+        try {
+            PackageManager packageManager = Consts.mApplicatonContext.getPackageManager();
+            if (packageManager != null) {
+                //注意此处为ApplicationInfo 而不是 ActivityInfo,因为友盟设置的meta-data是在application标签中,而不是某activity标签中,所以用ApplicationInfo
+                ApplicationInfo applicationInfo = packageManager.
+                        getApplicationInfo(Consts.mApplicatonContext.getPackageName(), PackageManager.GET_META_DATA);
+                if (applicationInfo != null) {
+                    if (applicationInfo.metaData != null) {
+                        code = String.valueOf(applicationInfo.metaData.get("UMENG_CHANNEL"));
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return code;
+    }
+
 }
 
+
 class PushHelper {
+
+
     public static void init(Context context) {
         //获取消息推送实例
         PushAgent pushAgent = PushAgent.getInstance(context);
+
+        String channelCode = EApplication.getChannelName();
+        if (channelCode.equals("2008")) {
+            //小米渠道
+            MiPushRegistar.register(context, "2882303761517510194", "r+ETScCARNYoaRwNV/BySw==", false);
+        } else if (channelCode.equals("2005")) {
+            //华为渠道
+            HuaWeiRegister.register(Consts.mApplicatonContext);
+        } else if (channelCode.equals("2007")) {
+            //vivo渠道
+            VivoRegister.register(context);
+        } else if (channelCode.equals("2004")) {
+            OppoRegister.register(context, "Dzb55KTW1gOoG8g408wSkwW08", "72cBB2D18C33571241C002748b964e3F");
+        }
+
         //注册推送服务,每次调用register方法都会回调该接口
         pushAgent.register(new UPushRegisterCallback() {
 

+ 2 - 1
src/org/cocos2dx/javascript/util/Consts.java

@@ -1,7 +1,8 @@
 package org.cocos2dx.javascript.util;
 
+import android.app.Application;
 import android.content.Context;
 
 public class Consts {
-    public static Context mApplicatonContext;
+    public static Application mApplicatonContext;
 }