Skip to content

Commit

Permalink
add vivo push (#3)
Browse files Browse the repository at this point in the history
vivo 应用商店上传版本
  • Loading branch information
SXiaoXu authored Mar 3, 2022
1 parent 9d84e62 commit 5e1632b
Show file tree
Hide file tree
Showing 33 changed files with 759 additions and 106 deletions.
Binary file modified .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions flutter_leave_lc/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
72 changes: 44 additions & 28 deletions flutter_leave_lc/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,53 @@ if (flutterVersionName == null) {
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdkVersion 28

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
compileSdkVersion flutter.compileSdkVersion

lintOptions {
disable 'InvalidPackage'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "leancloud.flutterapp"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
applicationId "com.example.flutterapplc"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode 1
versionName "1.0.0"
multiDexEnabled true
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
keyAlias 'flutter_rtm_demo_key'
keyPassword '123456'
storeFile file('/Users/xiaoxu/Documents/Flutter_WorkPlace/Keys/flutter_rtm_demo_key')
storePassword '123456'
}
debug {
keyAlias 'flutter_rtm_demo_key'
keyPassword '123456'
storeFile file('/Users/xiaoxu/Documents/Flutter_WorkPlace/Keys/flutter_rtm_demo_key')
storePassword '123456'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// signingConfig signingConfigs.release
// minifyEnabled true
// useProguard true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
minifyEnabled false
shrinkResources false
zipAlignEnabled false
signingConfig signingConfigs.release

minifyEnabled true
useProguard true

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Expand All @@ -74,8 +78,20 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation 'com.android.support:multidex:1.0.3'
//混合推送需要的包
implementation('cn.leancloud:mixpush-vivo:8.2.4')

//即时通信与推送需要的包
implementation 'cn.leancloud:realtime-android:8.2.4'
implementation 'cn.leancloud:storage-android:8.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'

implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.5.0'
}
Binary file not shown.
7 changes: 0 additions & 7 deletions flutter_leave_lc/android/app/proguard-rules.pro

This file was deleted.

52 changes: 42 additions & 10 deletions flutter_leave_lc/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutterapplc">
package="com.example.flutterapplc"
android:versionCode="1"
android:versionName="1.0.0">
<!-- 基本模块(必须)START -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<!-- 基本模块 END -->
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name=".MyApp"
android:label="LeanCN"
android:icon="@mipmap/ic_launcher">
android:allowBackup="true"
android:supportsRtl="true"
android:icon="@mipmap/ic_launcher"
>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand All @@ -33,5 +36,34 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<service
android:name="com.vivo.push.sdk.service.CommandClientService"
android:permission="com.push.permission.UPSTAGESERVICE"
android:exported="true"/>

<activity
android:name="com.vivo.push.sdk.LinkProxyClientActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar" /> <!-- push应用定义消息receiver声明 -->
<receiver android:name=".MyPushMessageReceiver"
android:exported="true">
<intent-filter>
<!-- 接收push消息 -->
<action android:name="com.vivo.pushclient.action.RECEIVE" />
</intent-filter>
</receiver>

<meta-data
android:name="com.vivo.push.api_key"
android:value="936bf546ba881586e1791a006935deba" />
<meta-data
android:name="com.vivo.push.app_id"
android:value="105541137" />

<!--vivo Push SDK的版本信息-->
<meta-data
android:name="sdk_version_vivo"
android:value="484"/>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.flutterapplc;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.util.Log;

import androidx.annotation.Nullable;

import com.vivo.push.PushClient;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
String regId = PushClient.getInstance(MainActivity.this).getRegId();
Log.d("regid"," regId= " + regId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.example.flutterapplc;

import cn.leancloud.LCException;
import cn.leancloud.LCInstallation;
import cn.leancloud.LCLogger;
import cn.leancloud.LCObject;
import cn.leancloud.LeanCloud;
import cn.leancloud.callback.LCCallback;
import cn.leancloud.vivo.LCMixPushManager;
import io.flutter.app.FlutterApplication;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class MyApp extends FlutterApplication {
private static final String LC_APP_ID = "eLAwFuK8k3eIYxh29VlbHu2N-gzGzoHsz";
private static final String LC_APP_KEY = "G59fl4C1uLIQVR4BIiMjxnM3";
private static final String LC_SERVER_URL = "https://elawfuk8.lc-cn-n1-shared.com";
// private static final String LC_APP_ID = "Gvv2k8PugDTmYOCfuK8tiWd8-gzGzoHsz";
// private static final String LC_APP_KEY = "dpwAo94n81jPsHVxaWwdxJVu";
// private static final String LC_SERVER_URL = "https://gvv2k8pu.lc-cn-n1-shared.com";
@Override
public void onCreate() {
super.onCreate();
LeanCloud.setLogLevel(LCLogger.Level.DEBUG);
LeanCloud.initialize(this, LC_APP_ID, LC_APP_KEY, LC_SERVER_URL);
System.out.println("打印 initialize = :" + "initialize" );
LCMixPushManager.registerVIVOPush(this);
LCMixPushManager.turnOnVIVOPush(new LCCallback<Boolean>() {
@Override
protected void internalDone0(Boolean aBoolean, LCException e) {
if (null != e) {
System.out.println("failed to turn on VIVO push. cause:");
e.printStackTrace();
} else {
System.out.println("succeed to turn on VIVO push.");
}
}
});
LCInstallation.getCurrentInstallation().saveInBackground().subscribe(new Observer<LCObject>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(LCObject avObject) {
// 关联 installationId 到用户表等操作。
String installationId = LCInstallation.getCurrentInstallation().getInstallationId();
System.out.println("保存成功:" + installationId );
}
@Override
public void onError(Throwable e) {
System.out.println("保存失败,错误信息:" + e.getMessage());
}
@Override
public void onComplete() {
}
});
String installationId = LCInstallation.getCurrentInstallation().getInstallationId();
System.out.println("打印 installationId = :" + installationId );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.flutterapplc;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.vivo.push.model.UnvarnishedMessage;

import java.util.logging.Logger;

import cn.leancloud.LCVIVOPushMessageReceiver;

public class MyPushMessageReceiver extends LCVIVOPushMessageReceiver {
private static final Logger logger = Logger.getLogger(MyPushMessageReceiver.class.getSimpleName());

@Override
public void onTransmissionMessage(Context context, UnvarnishedMessage unvarnishedMessage) {
super.onTransmissionMessage(context, unvarnishedMessage);
Toast.makeText(context, " 收到透传通知: " + unvarnishedMessage.getMessage(),
Toast.LENGTH_LONG).show();
Log.d("PushMessageReceiver", " onTransmissionMessage= "
+ unvarnishedMessage.getMessage());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions flutter_leave_lc/android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
12 changes: 11 additions & 1 deletion flutter_leave_lc/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
8 changes: 3 additions & 5 deletions flutter_leave_lc/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:7.0.4'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
1 change: 0 additions & 1 deletion flutter_leave_lc/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
Loading

0 comments on commit 5e1632b

Please sign in to comment.