vivo android system,Android集成vivo推送

①下载SDK,放到libs文件夹中。

db3d190f2dfa

image.png

②分别在gradle和AndroidManifest中配置好。

implementation files(‘libs/pushsdk_v2.3.4.jar’)

android:name=”com.vivo.push.api_key”

android:value=”xxxxxxxxxxxxx” />

android:name=”com.vivo.push.app_id”

android:value=”xxxxxxx” />

android:name=”com.vivo.push.sdk.service.CommandClientService”

android:exported=”true” />

android:name=”com.vivo.push.sdk.LinkProxyClientActivity”

android:exported=”false”

android:screenOrientation=”portrait”

android:theme=”@android:style/Theme.Translucent.NoTitleBar” />

③在application中初始化

/**

* 初始化vivo推送

*/

public static void initVivoPush(Context context) {

//初始化vivo推送

PushClient.getInstance(context).initialize();

//并且打开推送服务

PushClient.getInstance(context).turnOnPush(new IPushActionListener() {

@Override

public void onStateChanged(int i) {

if (i == 0) {

Log.e(“NPL”, “打开推送服务成功”);

} else {

Log.e(“NPL”, “打开推送服务失败”);

}

}

});

}

④编写receiver并在AndroidMenifest中注册

public class VivoPushMessageReceiver extends OpenClientPushMessageReceiver {

private int nativeRedirect=0;

private String url=””;

private int pageType=0;

private int newsType=0;

private long newsId=0;

private String thumb=””;

private String title = “”;

private String content = “”;

@Override

public void onNotificationMessageClicked(Context context, UPSNotificationMessage upsNotificationMessage) {

title = upsNotificationMessage.getTitle();

content = upsNotificationMessage.getContent();

Map map = upsNotificationMessage.getParams();

if (map.get(MessageEntity.NativeRedirect)!=null&&!map.get(MessageEntity.NativeRedirect).equals(“”)){

nativeRedirect = Integer.valueOf(map.get(MessageEntity.NativeRedirect));

}

url = map.get(MessageEntity.Link);

if (map.get(MessageEntity.PageType)!=null&&!map.get(MessageEntity.PageType).equals(“”)){

pageType = Integer.valueOf(map.get(MessageEntity.PageType));

}

if (map.get(MessageEntity.NewsType)!=null&&!map.get(MessageEntity.NewsType).equals(“”)){

newsType = Integer.valueOf(map.get(MessageEntity.NewsType));

}

if (map.get(MessageEntity.NewsId)!=null&&!map.get(MessageEntity.NewsId).equals(“”)){

newsId = Long.valueOf(map.get(MessageEntity.NewsId));

}

thumb = map.get(MessageEntity.Thumb);

}

@Override

public void onReceiveRegId(Context context, String s) {

SpUtil.saveNoClearString(context, SpKey.VIVO_PUSH_REGISTRATION_ID, s);

}

}

到这里已经全部配置完成。

原文链接:https://blog.csdn.net/weixin_35653679/article/details/117585560?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165277698816781818735295%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165277698816781818735295&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-10-117585560-null-null.nonecase&utm_term=vivo

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
文明发言,共建和谐米科社区
提交
头像

昵称

取消
昵称表情图片