Commit 5d7c0a19 authored by pengjunjign's avatar pengjunjign

add:添加vivo推送示例代码,以及推送测试模块

parent df1882da
......@@ -10,6 +10,16 @@
android:supportsRtl="true"
android:name=".MyApplication"
android:theme="@style/Theme.PushTestProject">
<!--Vivo Push开放平台中应用的appid 和api key-->
<meta-data
android:name="com.vivo.push.app_id"
android:value="105483822" />
<meta-data
android:name="com.vivo.push.api_key"
android:value="cca2ba3da947c84ca7544e78237fca1c" />
<!-- android:value="44df82ae6314b2c26704" />-->
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
......@@ -3,6 +3,7 @@ package com.laihua.pushtestproject
import android.app.Application
import com.laihua.push.PushManager
import com.laihua.push.platform.InitParam
import com.laihua.push.utils.LogUtils
/**
* Author: pengjunjing
......@@ -14,16 +15,31 @@ class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
PushManager.instance.initContext(this)
PushManager.instance.initMiPush(InitParam("2882303761519924093", "5121992433093"))
PushManager.instance.initHmsPush()
PushManager.instance.initMiPush(
InitParam("2882303761519924093", "5121992433093"),
{ LogUtils.i("小米推送SDK初始化成功:$it") },
{ LogUtils.i("小米推送SDK初始化失败:${it.message}") })
PushManager.instance.initHmsPush(
{ LogUtils.i("华为推送SDK初始化成功:$it") },
{ LogUtils.i("华为推送SDK初始化失败:${it.message}") })
//OPPO APPID 30532383
PushManager.instance.initOppoPush(
InitParam(
"220c8dc643ce4a709b116a0aa26e6bf4",
"0305238c1c6949c38caa1fdd8070b4aa"
)
InitParam("220c8dc643ce4a709b116a0aa26e6bf4", "0305238c1c6949c38caa1fdd8070b4aa"),
{ LogUtils.i("OPPO推送SDK初始化成功:$it") },
{ LogUtils.i("OPPO推送SDK初始化失败:${it.message}") }
)
PushManager.instance.initFlyMe(InitParam("141361", "f3e78d580c7d46c295263b3dde94ca72"))
PushManager.instance.initFlyMe(
InitParam("141361", "f3e78d580c7d46c295263b3dde94ca72"),
{ LogUtils.i("Flyme推送SDK初始化成功:$it") },
{ LogUtils.i("Flyme推送SDK初始化失败:${it.message}") })
//vivo的配置信息直接在manifest配置
PushManager.instance.initVivo(
{ LogUtils.i("VIVO推送SDK初始化成功:$it") },
{ LogUtils.i("VIVO推送SDK初始化失败:${it.message}") })
}
}
\ No newline at end of file
rootProject.name = "pushTestProject"
include ':app'
include ':push'
include ':vivoPushTestlib'
/build
\ No newline at end of file
plugins {
id 'java-library'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
\ No newline at end of file
package com.laihua.vivopushtestlib;
import com.vivo.push.sdk.notofication.Message;
import com.vivo.push.sdk.notofication.Result;
import com.vivo.push.sdk.server.Sender;
public class MyClass {
public static void main(String[] args) {
try {
//推送测试,运行之后可以直接在手机上收到推送.
Sender sender = new Sender("ccb2170d-3ded-499b-9779-f1a904edd98d");
Result result = sender.getToken(105483822 , "cca2ba3da947c84ca7544e78237fca1c");
sender.setAuthToken(result. getAuthToken());
Message singleMessage = new Message.Builder()
//将此id改为手机注册成功之后的id,可能需要在vivo后台添加为测试设备
.regId("16214127740408382238160")
.notifyType(3)
.title("push title test1111")
.content("push content test 22222")
.timeToLive(1000)
.skipType(2)
.skipContent("https://www.baidu.com")
.networkType(-1)
.requestId("16214127740408382238160")
.pushMode(1)
.build();
Result resultMessage = sender.sendSingle(singleMessage);
System.out.println(resultMessage);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment