组件和应用信息配置
TPNS Android SDK 1.1.6.3及之前版本请注意使用以下配置:
<application><!-- 应用的其它配置 --><uses-library android:name="org.apache.http.legacy" android:required="false"/><!-- 【必须】 移动推送 TPNS 默认通知 --><activityandroid:name="com.tencent.android.tpush.XGPushActivity"><intent-filter><action android:name="android.intent.action" /></intent-filter></activity><!-- 【必须】 移动推送 TPNS receiver广播接收 --><receiverandroid:name="com.tencent.android.tpush.XGPushReceiver"android:process=":xg_vip_service"><intent-filter android:priority="0x7fffffff"><!-- 【必须】 移动推送 TPNS SDK的内部广播 --><action android:name="com.tencent.android.xg.vip.action.SDK" /><action android:name="com.tencent.android.xg.vip.action.INTERNAL_PUSH_MESSAGE" /><action android:name="com.tencent.android.xg.vip.action.ACTION_SDK_KEEPALIVE" /><!-- 【可选】 系统广播:网络切换 --><action android:name="android.net.conn.CONNECTIVITY_CHANGE" /><!-- 【可选】 系统广播:开屏 --><action android:name="android.intent.action.USER_PRESENT" /><!-- 【可选】 一些常用的系统广播,增强移动推送 TPNS service的复活机会,请根据需要选择。当然,您也可以添加App自定义的一些广播让启动service --><action android:name="android.bluetooth.adapter.action.STATE_CHANGED" /><action android:name="android.intent.action.ACTION_POWER_CONNECTED" /><action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" /></intent-filter></receiver><!-- 【必须】 移动推送 TPNS service --><serviceandroid:name="com.tencent.android.tpush.service.XGVipPushService"android:persistent="true"android:process=":xg_vip_service"></service><!-- 【必须】 通知service,其中android:name部分要改为当前包名 --><service android:name="com.tencent.android.tpush.rpc.XGRemoteService"android:exported="false"><intent-filter><!-- 【必须】 请修改为当前APP名包.XGVIP_PUSH_ACTION --><action android:name="应用包名.XGVIP_PUSH_ACTION" /></intent-filter></service><!-- 【必须】 【注意】authorities修改为 包名.XGVIP_PUSH_AUTH --><providerandroid:name="com.tencent.android.tpush.XGPushProvider"android:authorities="应用包名.XGVIP_PUSH_AUTH" /><!-- 【必须】 【注意】authorities修改为 包名.TPUSH_PROVIDER --><providerandroid:name="com.tencent.android.tpush.SettingsContentProvider"android:authorities="应用包名.TPUSH_PROVIDER" /><!-- 【可选】用于增强保活能力 --><providerandroid:name="com.tencent.android.tpush.XGVipPushKAProvider"android:authorities="应用包名.AUTH_XGPUSH_KEEPALIVE"android:exported="true" /><!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 --><!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: --><receiver android:name="应用包名.MessageReceiver"><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><!-- MQTT START --><service android:exported="false"android:process=":xg_vip_service"android:name="com.tencent.bigdata.mqttchannel.services.MqttService" /><!--【注意】authorities修改为 包名.XG_SETTINGS_PROVIDER, 如demo的包名为:com.tencent.android.xg.cloud.demo --><providerandroid:exported="false"android:name="com.tencent.bigdata.baseapi.base.SettingsContentProvider"android:authorities="应用包名.XG_SETTINGS_PROVIDER" /><!-- MQTT END--><!-- 【必须】 请修改为 APP 的 AccessId,“15”开头的10位数字,中间没空格 --><meta-dataandroid:name="XG_V2_ACCESS_ID"android:value="APP的AccessId" /><!-- 【必须】 请修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 --><meta-dataandroid:name="XG_V2_ACCESS_KEY"android:value="APP的AccessKey" /></application><!-- 【必须】 移动推送 TPNS SDK 5.0版本所需权限 --><permissionandroid:name="应用包名.permission.XGPUSH_RECEIVE"android:protectionLevel="signature" /><uses-permission android:name="应用包名.permission.XGPUSH_RECEIVE" /><!-- 【必须】 移动推送 TPNS SDK所需权限 --><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.WAKE_LOCK" /><!-- 【常用】 移动推送 TPNS SDK所需权限 --><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /><uses-permission android:name="android.permission.READ_PHONE_STATE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
注意
如果您的应用服务接入点为广州,SDK 默认实现该配置。
如果您的应用服务接入点为新加坡或者中国香港,请按照下文步骤完成境外服务接入点配置。
在 AndroidManifest 文件 application 标签内添加以下元数据:
<application>// 其他安卓组件<meta-dataandroid:name="XG_GUID_SERVER"android:value="境外域名/guid/api/GetGuidAndMqttServer" /><meta-dataandroid:name="XG_STAT_SERVER"android:value="境外域名/log/statistics/push" /><meta-dataandroid:name="XG_LOG_SERVER"android:value="境外域名/v3/mobile/log/upload" /></application>
境外域名如下:
新加坡:
https://api.tpns.sgp.tencent.com
中国香港:
https://api.tpns.hk.tencent.com