33import android .app .Application ;
44import android .content .Context ;
55
6+ import com .vivo .push .PushConfig ;
7+ import com .vivo .push .listener .IPushQueryActionListener ;
8+
69import java .util .List ;
710
811import 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