Commit 5a2a1032 authored by sheteng's avatar sheteng

推送

parent 657a6ce9
......@@ -22,21 +22,13 @@ android {
}
}
// compileSdk 30
// defaultConfig {
// applicationId = "com.ccwangluo.accelerator"
// minSdk 21
// targetSdk 30
// versionCode = 1
// versionName = "1.0"
//
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// javaCompileOptions {
// annotationProcessor(Options {)
// arguments = listOf( moduleName : project.getName() )
// }
// }
// manifestPlaceholders = listOf(qqappid = "你的qq appid")
// }
defaultConfig {
applicationId = "com.ccwangluo.accelerator"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders.put("XG_ACCESS_ID","1580009634")
manifestPlaceholders.put("XG_ACCESS_KEY","AIJKAIYR3WPS")
}
buildTypes {
named("release"){
......@@ -120,4 +112,5 @@ dependencies {
annotationProcessor("com.github.bumptech.glide:compiler:4.11.0")
implementation("com.github.open-android:JieCaoVideoPlayer:0.1.0")
implementation("com.tencent.tpns:tpns:1.3.2.0-release")
}
\ No newline at end of file
......@@ -165,3 +165,13 @@
-dontwarn org.eclipse.jdt.annotation.**
-dontwarn c.t.**
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep class com.tencent.android.tpush.** {*;}
-keep class com.tencent.tpns.baseapi.** {*;}
-keep class com.tencent.tpns.mqttchannel.** {*;}
-keep class com.tencent.tpns.dataacquisition.** {*;}
-keep class com.tencent.bigdata.baseapi.** {*;} // 1.2.0.1 及以上版本不需要此条配置
-keep class com.tencent.bigdata.mqttchannel.** {*;} // 1.2.0.1 及以上版本不需要此条配置
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.ccwangluo.accelerator">
<!-- 【必须】 移动推送 TPNS SDK VIP版本所需权限 -->
<permission
android:name="com.ccwangluo.accelerator.permission.XGPUSH_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.ccwangluo.accelerator.permission.XGPUSH_RECEIVE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
......@@ -17,9 +23,9 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- 支持A-GPS辅助定位 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 用于 log 日志 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<queries>
<package android:name="com.tencent.mm" />
<package android:name="com.tencent.mobileqq" />
......@@ -34,6 +40,7 @@
<package android:name="com.tencent.mm" />
<package android:name="com.goplaycn.googleinstall" />
<package android:name="io.kkzs" />
<package android:name="com.eg.android.AlipayGphone" />
</queries>
......@@ -68,6 +75,26 @@
android:name="TencentMapSDK"
android:value="KZFBZ-QJ26J-WAYFC-FIO5N-FE453-QTFTT" />
<meta-data
android:name="XG_SERVER_SUFFIX"
android:value="tpns.sh.tencent.com" />
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<receiver android:name=".receiver.MyXGPushBaseReceiver">
<intent-filter>
<!-- 接收消息透传 -->
<action android:name="com.tencent.android.xg.vip.action.PUSH_MESSAGE" />
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
<action android:name="com.tencent.android.xg.vip.action.FEEDBACK" />
</intent-filter>
</receiver>
<!-- 在自身应用的AndroidManifest.xml文件中添加如下结点,其中 xxx 为任意自定义名称: -->
<!-- 关闭与 TPNS 应用的联合保活功能,请配置 -->
<provider
android:name="com.tencent.android.tpush.XGPushProvider"
tools:replace="android:authorities"
android:authorities="com.ccwangluo.accelerator.ccwangluo.XGVIP_PUSH_AUTH"
android:exported="false" />
<activity
android:name=".wxapi.WXEntryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
......
......@@ -8,6 +8,7 @@ import com.ccwangluo.accelerator.ui.MainActivity
import com.ccwangluo.accelerator.utils.PhoneUtils
import com.github.shadowsocks.Core
import com.hjq.toast.ToastUtils
import com.tencent.android.tpush.XGPushConfig
import com.tencent.map.geolocation.TencentLocationManager
import com.tencent.mmkv.MMKV
import com.xuexiang.xpage.PageConfig
......@@ -28,6 +29,7 @@ class App : Application(), androidx.work.Configuration.Provider by Core {
MultiDex.install(this)
Core.init(this, MainActivity::class)
MMKV.initialize(this)
XGPushConfig.enableDebug(this,true);
}
override fun onConfigurationChanged(newConfig: Configuration) {
......
package com.ccwangluo.accelerator.receiver
import android.content.Context
import com.tencent.android.tpush.*
class MyXGPushBaseReceiver : XGPushBaseReceiver (){
override fun onRegisterResult(p0: Context?, p1: Int, p2: XGPushRegisterResult?) {
}
override fun onUnregisterResult(p0: Context?, p1: Int) {
}
override fun onSetTagResult(p0: Context?, p1: Int, p2: String?) {
}
override fun onDeleteTagResult(p0: Context?, p1: Int, p2: String?) {
}
override fun onSetAccountResult(p0: Context?, p1: Int, p2: String?) {
}
override fun onDeleteAccountResult(p0: Context?, p1: Int, p2: String?) {
}
override fun onSetAttributeResult(p0: Context?, p1: Int, p2: String?) {
}
override fun onQueryTagsResult(p0: Context?, p1: Int, p2: String?, p3: String?) {
}
override fun onDeleteAttributeResult(p0: Context?, p1: Int, p2: String?) {
}
override fun onTextMessage(p0: Context?, p1: XGPushTextMessage?) {
}
override fun onNotificationClickedResult(p0: Context?, p1: XGPushClickedResult?) {
}
override fun onNotificationShowedResult(p0: Context?, p1: XGPushShowedResult?) {
}
}
\ No newline at end of file
......@@ -32,11 +32,18 @@ import com.xuexiang.xpage.core.PageOption
import android.hardware.SensorManager
import android.hardware.SensorEventListener
import android.os.Handler
import android.util.Log
import com.ccwangluo.accelerator.utils.SysUtils
import com.xuexiang.xutil.net.NetworkUtils
import com.xuexiang.xutil.system.PermissionUtils
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer
import java.security.Permission
import com.tencent.android.tpush.XGIOperateCallback
import com.tencent.android.tpush.XGPushManager
class MainActivity() : XPageActivity(), TencentLocationListener {
......@@ -112,6 +119,17 @@ class MainActivity() : XPageActivity(), TencentLocationListener {
private fun initPhoneUtils() {
PhoneUtils.getPhoneInfo()
//腾讯推送
XGPushManager.registerPush(this, object : XGIOperateCallback {
override fun onSuccess(data: Any, flag: Int) {
//token在设备卸载重装的时候有可能会变
Log.d("TPush", "注册成功,设备token为:$data")
}
override fun onFail(data: Any, errCode: Int, msg: String) {
Log.d("TPush", "注册失败,错误码:$errCode,错误信息:$msg")
}
})
}
override fun onBackPressed() {
......
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/xg_root_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--通知的背景,id名字不能改变,其他可变-->
<ImageView
android:id="@+id/xg_notification_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<!--通知的大图标,id名字不能改变,其他可变.必须-->
<ImageView
android:id="@+id/xg_notification_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:scaleType="centerInside" />
<!--通知的时间,id名字不能改变,其他可变.若不显示时间可以去掉此布局-->
<TextView
android:id="@+id/xg_notification_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:textSize="12dp" />
<!--通知的标题,id名字不能改变,其他可变。必须-->
<TextView
android:id="@+id/xg_notification_style_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_toLeftOf="@id/xg_notification_date"
android:layout_toRightOf="@id/xg_notification_icon"
android:singleLine="true" />
<!--通知的内容,id名字不能改变,其他可变。必须-->
<TextView
android:id="@+id/xg_notification_style_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/xg_notification_style_title"
android:layout_alignLeft="@+id/xg_notification_style_title"
android:layout_marginTop="1dp"
android:layout_toLeftOf="@id/xg_notification_date"
android:singleLine="true" />
<!--带音频的富媒体通知的音频播放按钮,id名字不能改变,其他可变。若没用到音频富媒体可以去掉此布局-->
<ImageView
android:id="@+id/xg_notification_audio_play"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignLeft="@+id/xg_notification_style_title"
android:layout_alignParentBottom="true"
android:background="@android:drawable/ic_media_play"
android:visibility="gone" />
<!--带音频的富媒体通知的音频停止播放按钮,id名字不能改变,其他可变.若没用到音频富媒体可以去掉此布局-->
<ImageView
android:id="@+id/xg_notification_audio_stop"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="30dp"
android:layout_toRightOf="@+id/xg_notification_audio_play"
android:background="@android:drawable/ic_media_pause"
android:visibility="gone" />
</RelativeLayout>
\ 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