Skip to content

TencentCloud/TPNS-Flutter-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a534937 · Mar 26, 2025
Nov 20, 2024
Mar 26, 2025
Mar 26, 2025
May 8, 2024
Mar 26, 2025
Mar 26, 2025
Oct 27, 2023
Jun 11, 2021
Nov 20, 2024
Jun 15, 2021
Mar 26, 2025
Sep 28, 2020
Mar 26, 2025
Sep 28, 2020
Nov 20, 2024
Nov 20, 2024
Mar 26, 2025
Sep 28, 2020

Repository files navigation

tpns_flutter_plugin

安装

  • 在工程 pubspec.yaml 中加入 dependencies,在命令行中运行:flutter pub get进行安装
      dependencies:
        tpns_flutter_plugin:
          git:
            url: https://github.com/TencentCloud/TPNS-Flutter-Plugin
            ref: V1.3.4
  • 注意:由于TPNS插件名变更xg_flutter_plugin->tpns_flutter_plugin,更新插件时V1.0.4及以上版本请使用tpns_flutter_plugin

使用

集群域名配置(如果您的应用非广州集群请按照以下方法进行域名配置,广州集群请忽略)

说明 : 此接口V1.2.7开始支持安卓,若您插件版本>=1.2.7,建议您将原来的Manifest对应域名设置删除,以接口为准.

集群域名:

   中国上海:tpns.sh.tencent.com
   中国香港:tpns.hk.tencent.com
   新加坡:tpns.sgp.tencent.com
  • 需要在注册方法startXg之前调用以下域名配置函数
    • domainStr 对应集群域名
      void configureClusterDomainName(String domainStr);

iOS

  • 执行flutter pub get安装好插件后进入iOS文件目录(cd ios)执行:pod install安装依赖库
  • 在 xcode8 之后需要点开推送选项: TARGETS -> Capabilities -> Push Notification 设为 on 状态
      import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
  说明(接口使用参考/tpns_flutter_plugin/example/lib/main.dart和/tpns_flutter_plugin/example/lib/ios/homeTest.dart文件)

Android

1. 环境配置

      android: {
         ....
         defaultConfig {
           applicationId "替换成自己应用 ID"
           ...
           ndk {
        /// 选择要添加的对应.so 库。
        abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a',
           }
           //
           manifestPlaceholders = [
               XG_ACCESS_ID : "替换自己的ACCESS_ID",  // 信鸽官网注册所得ACCESS_ID
               XG_ACCESS_KEY : "替换自己的ACCESS_KEY",  // 信鸽官网注册所得ACCESS_KEY
    
           ]
         }
       }

2. 代码混淆

      -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.** {*;}   // TPNS-Android-SDK 1.2.0.1 及以上版本不需要此条配置
      -keep class com.tencent.bigdata.mqttchannel.** {*;}  // TPNS-Android-SDK 1.2.0.1 及以上版本不需要此条配置

3. 厂商通道接入说明

说明 : 提供安卓各厂商通道接入方法。

点击查看

启用推送

  /// iOS前台收到通知不希望展示时可将withInAppAlert参数置为false
  /// android 接入厂商通道时,请在此注册方法前调用各厂商通道参数配置接口
      void startXg(String accessId, String accessKey, {bool withInAppAlert = true});

APIs

说明 : 提供TPNS的所有业务接口。

点击查看

TPNS-Flutter 使用常见问题参考

点击查看