Skip to content

Commit 846fb6a

Browse files
authored
upgrade vivo push to 3.0.0.7 (#243)
1 parent 416beb5 commit 846fb6a

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

android-sdk/mixpush-android/src/main/java/cn/leancloud/LCMixPushManager.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,21 @@ public static void setFlymeMStatusbarIcon(int icon) {
313313
/**
314314
* 初始化方法,建议在 Application onCreate 里面调用
315315
* @param application application
316+
* @param agreePrivacyStatement boolean. true:用户同意了隐私声明;false:未同意隐私声明。
316317
*/
317-
public static boolean registerVIVOPush(Application application) {
318-
return cn.leancloud.vivo.LCMixPushManager.registerVIVOPush(application);
318+
public static boolean registerVIVOPush(Application application, boolean agreePrivacyStatement) {
319+
return cn.leancloud.vivo.LCMixPushManager.registerVIVOPush(application, agreePrivacyStatement);
319320
}
320321

321322
/**
322323
* 初始化方法,建议在 Application onCreate 里面调用
323324
* @param application application
325+
* @param profile user profile.
326+
* @param agreePrivacyStatement boolean. true:用户同意了隐私声明;false:未同意隐私声明。
324327
*/
325-
public static boolean registerVIVOPush(Application application, String profile) {
326-
return cn.leancloud.vivo.LCMixPushManager.registerVIVOPush(application, profile);
328+
public static boolean registerVIVOPush(Application application, String profile,
329+
boolean agreePrivacyStatement) {
330+
return cn.leancloud.vivo.LCMixPushManager.registerVIVOPush(application, profile, agreePrivacyStatement);
327331
}
328332

329333
/**

android-sdk/mixpush-vivo/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dependencies {
6767

6868
implementation("cn.leancloud:realtime-core:${rootProject.ext.sdkVersion}")
6969

70-
implementation files("libs/vivo_pushSDK_v3.0.0.4_484.aar")
70+
implementation files("libs/vivo_pushSDK_v3.0.0.7_488.aar")
7171

7272
testImplementation 'junit:junit:4.12'
7373
androidTestImplementation 'androidx.test:runner:1.1.0'
-158 KB
Binary file not shown.
222 KB
Binary file not shown.

android-sdk/mixpush-vivo/src/main/java/cn/leancloud/vivo/LCMixPushManager.java

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import android.app.Application;
44
import android.content.Context;
55

6+
import com.vivo.push.PushConfig;
7+
import com.vivo.push.listener.IPushQueryActionListener;
8+
69
import java.util.List;
710

811
import cn.leancloud.LCException;
@@ -32,19 +35,21 @@ public class LCMixPushManager {
3235
/**
3336
* 初始化方法,建议在 Application onCreate 里面调用
3437
* @param application application
38+
* @param agreePrivacyStatement boolean. true:用户同意了隐私声明;false:未同意隐私声明。
3539
* @return true - succeed, false - failed.
3640
*/
37-
public static boolean registerVIVOPush(Application application) {
38-
return LCMixPushManager.registerVIVOPush(application, "");
41+
public static boolean registerVIVOPush(Application application, boolean agreePrivacyStatement) {
42+
return LCMixPushManager.registerVIVOPush(application, "", agreePrivacyStatement);
3943
}
4044

4145
/**
4246
* 初始化方法,建议在 Application onCreate 里面调用
4347
* @param application application
4448
* @param profile profile
49+
* @param agreePrivacyStatement boolean. true:用户同意了隐私声明;false:未同意隐私声明。
4550
* @return true - succeed, false - failed.
4651
*/
47-
public static boolean registerVIVOPush(Application application, String profile) {
52+
public static boolean registerVIVOPush(Application application, String profile, boolean agreePrivacyStatement) {
4853
vivoDeviceProfile = profile;
4954
if (null == application) {
5055
return false;
@@ -56,7 +61,10 @@ public static boolean registerVIVOPush(Application application, String profile)
5661
printErrorLog("current device doesn't support VIVO Push.");
5762
return false;
5863
}
59-
client.initialize();
64+
PushConfig config = new PushConfig.Builder()
65+
.agreePrivacyStatement(agreePrivacyStatement)
66+
.build();
67+
client.initialize(config);
6068
return true;
6169
} catch (com.vivo.push.util.VivoPushException ex) {
6270
printErrorLog("register error, mainifest is incomplete! details=" + ex.getMessage());
@@ -69,11 +77,28 @@ public static boolean registerVIVOPush(Application application, String profile)
6977
* @param context context.
7078
* @return registration id.
7179
*/
72-
public static String getRegistrationId(Context context) {
80+
public static void getRegistrationId(Context context, final LCCallback<String> callback) {
7381
if (null == context) {
74-
return null;
82+
if (null != callback) {
83+
callback.internalDone(new LCException(LCException.INVALID_PARAMETER, "context is invalid."));
84+
}
85+
return;
7586
}
76-
return com.vivo.push.PushClient.getInstance(context).getRegId();
87+
com.vivo.push.PushClient.getInstance(context).getRegId(new IPushQueryActionListener() {
88+
@Override
89+
public void onSuccess(String s) {
90+
if (null != callback) {
91+
callback.internalDone(s, null);
92+
}
93+
}
94+
95+
@Override
96+
public void onFail(Integer integer) {
97+
if (null != callback) {
98+
callback.internalDone(new LCException(LCException.UNKNOWN, "PushClient error. code:" + integer));
99+
}
100+
}
101+
});
77102
}
78103
/**
79104
* turn off VIVO push.

0 commit comments

Comments
 (0)