xuqm 1 year ago
parent
commit
acd57b3724

+ 0 - 17
.idea/deploymentTargetDropDown.xml

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="deploymentTargetDropDown">
-    <runningDeviceTargetSelectedWithDropDown>
-      <Target>
-        <type value="RUNNING_DEVICE_TARGET" />
-        <deviceKey>
-          <Key>
-            <type value="SERIAL_NUMBER" />
-            <value value="192.168.115.170:43303" />
-          </Key>
-        </deviceKey>
-      </Target>
-    </runningDeviceTargetSelectedWithDropDown>
-    <timeTargetWasSelectedWithDropDown value="2023-06-06T09:25:14.359761300Z" />
-  </component>
-</project>

+ 1 - 0
.idea/gradle.xml

@@ -11,6 +11,7 @@
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/SzyxImSdk" />
+            <option value="$PROJECT_DIR$/SzyxPushSdk" />
             <option value="$PROJECT_DIR$/app" />
           </set>
         </option>

+ 2 - 1
app/build.gradle

@@ -50,11 +50,12 @@ android {
     }
 }
 dependencies {
-//    implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
+    implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
 
 
 
     api project(path: ':SzyxImSdk')
+    api project(path: ':SzyxPushSdk')
     implementation 'androidx.appcompat:appcompat:1.4.2'
     implementation 'com.google.android.material:material:1.5.0'
     implementation 'androidx.constraintlayout:constraintlayout:2.1.3'

BIN
app/libs/SzyxImSdk-release.aar


+ 8 - 2
app/src/main/AndroidManifest.xml

@@ -20,8 +20,7 @@
             android:exported="false" />
         <activity
             android:name=".ui.login.LoginActivity"
-            android:exported="true"
-            android:label="@string/title_activity_login">
+            android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
@@ -37,6 +36,13 @@
         <activity
             android:name=".ui.FriendsActivity"
             android:exported="true" />
+        <meta-data
+            android:name="api_key"
+            android:value="f1915413758c27b8380eee038456b39c"/>
+
+        <meta-data
+            android:name="app_id"
+            android:value="105654149"/>
     </application>
 
 </manifest>

+ 3 - 0
app/src/main/java/cn/org/bjca/trust/android/imdemo/ui/MainActivity.java

@@ -10,12 +10,14 @@ import com.xuqm.base.adapter.CommonPagedAdapter;
 import com.xuqm.base.adapter.ViewHolder;
 import com.xuqm.base.ui.BaseListFormLayoutActivity;
 
+import cn.org.bjca.trust.android.imdemo.MyApplication;
 import cn.org.bjca.trust.android.imdemo.R;
 import cn.org.bjca.trust.android.imdemo.data.item.MainItem;
 import cn.org.bjca.trust.android.imdemo.databinding.ActivityMainBinding;
 import cn.org.bjca.trust.android.imdemo.vm.MainVM;
 import cn.org.bjca.trust.android.lib.im.SZYXImSdk;
 import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
+import cn.org.bjca.trust.android.lib.push.SZYXPushSdk;
 
 public class MainActivity extends BaseListFormLayoutActivity<MainItem, MainVM, ActivityMainBinding> {
 
@@ -29,6 +31,7 @@ public class MainActivity extends BaseListFormLayoutActivity<MainItem, MainVM, A
         super.initView(savedInstanceState);
         showBack(false);
         setTitleText("工作台");
+        SZYXPushSdk.getInstance().init(MyApplication.getInstance());
         setConfirmText("退出", v -> SZYXImSdk.getInstance().logout(new IMSDKCallback() {
             @Override
             public void success() {

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -1,5 +1,5 @@
 <resources>
-    <string name="app_name">ImAndroid</string>
+    <string name="app_name">推送demo</string>
     <string name="title_activity_login">LoginActivity</string>
     <string name="prompt_email">Phone</string>
     <string name="prompt_password">Password</string>

+ 1 - 0
settings.gradle

@@ -27,3 +27,4 @@ dependencyResolutionManagement {
 rootProject.name = "ImAndroid"
 include ':app'
 include ':SzyxImSdk'
+include ':SzyxPushSdk'

+ 1 - 0
szyxpushsdk/.gitignore

@@ -0,0 +1 @@
+/build

+ 37 - 0
szyxpushsdk/build.gradle

@@ -0,0 +1,37 @@
+plugins {
+    id 'com.android.library'
+}
+
+android {
+    namespace 'cn.org.bjca.trust.android.lib.push'
+    compileSdk 33
+
+    defaultConfig {
+        minSdk 24
+        targetSdk 33
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        consumerProguardFiles "consumer-rules.pro"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+}
+
+dependencies {
+    implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
+    implementation 'androidx.appcompat:appcompat:1.4.2'
+    implementation 'com.google.android.material:material:1.5.0'
+    testImplementation 'junit:junit:4.13.2'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+
+}

+ 0 - 0
szyxpushsdk/consumer-rules.pro


BIN
szyxpushsdk/libs/vivo_pushSDK_v3.0.0.4_484.aar


+ 21 - 0
szyxpushsdk/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 26 - 0
szyxpushsdk/src/androidTest/java/cn/org/bjca/trust/android/lib/push/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package cn.org.bjca.trust.android.lib.push;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+        assertEquals("cn.org.bjca.trust.android.lib.push.test", appContext.getPackageName());
+    }
+}

+ 18 - 0
szyxpushsdk/src/main/AndroidManifest.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+<application>
+    <!--push应用定义消息receiver声明-->
+    <receiver android:name=".push.PushMessageReceiverImpl"
+        android:exported="false">
+        <intent-filter>
+            <!--接收push消息-->
+            <action android:name="com.vivo.pushclient.action.RECEIVE"/>
+        </intent-filter>
+    </receiver>
+    <!--Vivo Push需要配置的service、activity-->
+    <service
+        android:name="com.vivo.push.sdk.service.CommandClientService"
+        android:permission="com.push.permission.UPSTAGESERVICE"
+        android:exported="true"/>
+</application>
+</manifest>

+ 14 - 0
szyxpushsdk/src/main/java/cn/org/bjca/trust/android/lib/push/SZYXPushSdk.java

@@ -0,0 +1,14 @@
+package cn.org.bjca.trust.android.lib.push;
+
+import cn.org.bjca.trust.android.lib.push.kit.PushInterface;
+import cn.org.bjca.trust.android.lib.push.push.SZYXPushManager;
+
+public class SZYXPushSdk {
+    private static final class PushHolder {
+        static final PushInterface instance = new SZYXPushManager();
+    }
+
+    public static PushInterface getInstance() {
+        return PushHolder.instance;
+    }
+}

+ 7 - 0
szyxpushsdk/src/main/java/cn/org/bjca/trust/android/lib/push/kit/PushInterface.java

@@ -0,0 +1,7 @@
+package cn.org.bjca.trust.android.lib.push.kit;
+
+import android.content.Context;
+
+public interface PushInterface {
+    void init(Context mContext);
+}

+ 6 - 0
szyxpushsdk/src/main/java/cn/org/bjca/trust/android/lib/push/push/PushMessageReceiverImpl.java

@@ -0,0 +1,6 @@
+package cn.org.bjca.trust.android.lib.push.push;
+
+import com.vivo.push.sdk.OpenClientPushMessageReceiver;
+
+public class PushMessageReceiverImpl extends OpenClientPushMessageReceiver {
+}

+ 27 - 0
szyxpushsdk/src/main/java/cn/org/bjca/trust/android/lib/push/push/SZYXPushManager.java

@@ -0,0 +1,27 @@
+package cn.org.bjca.trust.android.lib.push.push;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.vivo.push.PushClient;
+import com.vivo.push.util.VivoPushException;
+
+import cn.org.bjca.trust.android.lib.push.kit.PushInterface;
+
+public class SZYXPushManager implements PushInterface {
+    @Override
+    public void init(Context mContext) {
+        //初始化push
+        try {
+            PushClient.getInstance(mContext).initialize();
+        } catch (VivoPushException e) {
+            Log.e("=====>0", e.getMessage());
+        }
+
+        // 打开push开关, 关闭为turnOffPush,详见api接入文档
+        PushClient.getInstance(mContext).turnOnPush(state -> {
+            Log.e("=====>1", state + "");
+            Log.e("=====>2", PushClient.getInstance(mContext).getRegId());
+        });
+    }
+}

+ 17 - 0
szyxpushsdk/src/test/java/cn/org/bjca/trust/android/lib/push/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package cn.org.bjca.trust.android.lib.push;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+    @Test
+    public void addition_isCorrect() {
+        assertEquals(4, 2 + 2);
+    }
+}